Zelda Classic Coverage Report


Directory: src/
File: src/zc/zc_sys.cpp
Date: 2023-09-29 08:11:57
Exec Total Coverage
Lines: 1676 4280 39.2%
Functions: 130 334 38.9%
Branches: 926 2868 32.3%

Line Branch Exec Source
1 #include "zc/zc_sys.h"
2
3 #include "allegro/gfx.h"
4 #include "allegro5/joystick.h"
5 #include "base/qrs.h"
6 #include "base/dmap.h"
7 #include <stdio.h>
8 #include <stdlib.h>
9 #include <cstring>
10 #include <math.h>
11 #include <map>
12 #include <filesystem>
13 #include <ctype.h>
14 #include <sstream>
15 #include "base/zc_alleg.h"
16 #include "gamedata.h"
17 #include "zc/zc_init.h"
18 #include "init.h"
19 #include "zc/replay.h"
20 #include "zc/cheats.h"
21 #include "zc/render.h"
22 #include "base/zc_math.h"
23 #include "base/zapp.h"
24 #include "dialog/cheatkeys.h"
25 #include "metadata/metadata.h"
26 #include "zc/zelda.h"
27 #include "zc/saves.h"
28 #include "tiles.h"
29 #include "base/colors.h"
30 #include "pal.h"
31 #include "base/zsys.h"
32 #include "qst.h"
33 #include "zc/zc_sys.h"
34 #include "play_midi.h"
35 #include "jwin_a5.h"
36 #include "base/jwinfsel.h"
37 #include "base/gui.h"
38 #include "midi.h"
39 #include "subscr.h"
40 #include "zc/maps.h"
41 #include "sprite.h"
42 #include "zc/guys.h"
43 #include "zc/hero.h"
44 #include "zc/title.h"
45 #include "particles.h"
46 #include "zcmusic.h"
47 #include "zconsole.h"
48 #include "zc/ffscript.h"
49 #include "dialog/info.h"
50 #include "dialog/alert.h"
51 #include "zc/combos.h"
52 #include "zc/jit.h"
53 #include "zc/zc_subscr.h"
54 #include <fmt/format.h>
55 #include "zinfo.h"
56 #include "base/misctypes.h"
57
58 #ifdef __EMSCRIPTEN__
59 #include "base/emscripten_utils.h"
60 #endif
61
62 using namespace std::chrono_literals;
63
64 extern FFScript FFCore;
65 extern bool Playing;
66 int32_t sfx_voice[WAV_COUNT];
67 int32_t d_stringloader(int32_t msg,DIALOG *d,int32_t c);
68 int32_t d_midilist_proc(int32_t msg,DIALOG *d,int32_t c);
69 static int32_t d_joylist_proc(int32_t msg,DIALOG *d,int32_t c);
70
71 extern byte monochrome_console;
72
73 extern HeroClass Hero;
74 extern zcmodule moduledata;
75 extern sprite_list guys, items, Ewpns, Lwpns, chainlinks, decorations;
76 extern particle_list particles;
77 extern int32_t loadlast;
78 extern char *sfx_string[WAV_COUNT];
79 byte use_dwm_flush;
80 byte use_save_indicator;
81 int32_t paused_midi_pos = 0;
82 byte midi_suspended = 0;
83 byte zc_192b163_warp_compatibility;
84 char modulepath[2048];
85 bool epilepsyFlashReduction;
86 signed char pause_in_background_menu_init = 0;
87 byte pause_in_background = 0;
88 bool is_sys_pal = false;
89 static bool load_control_called_this_frame;
90 extern PALETTE* hw_palette;
91 extern bool update_hw_pal;
92 extern const char* dmaplist(int32_t index, int32_t* list_size);
93 int32_t getnumber(const char *prompt,int32_t initialval);
94
95 extern bool kb_typing_mode; //script only, for disbaling key presses affecting Hero, etc.
96 extern int32_t cheat_modifier_keys[4]; //two options each, default either control and either shift
97
98 #if defined(ALLEGRO_WINDOWS)
99 const char *qst_dir_name = "win_qst_dir";
100 #elif defined(ALLEGRO_LINUX)
101 const char *qst_dir_name = "linux_qst_dir";
102 #elif defined(__APPLE__)
103 const char *qst_dir_name = "osx_qst_dir";
104 #endif
105 static const char *qst_module_name = "current_module";
106 #ifdef ALLEGRO_LINUX
107 static const char *samplepath = "samplesoundset/patches.dat";
108 #endif
109 char qst_files_path[2048];
110
111 #ifdef _MSC_VER
112 #define getcwd _getcwd
113 #endif
114
115 bool rF11();
116 bool rI();
117 bool rQ();
118 bool zc_key_pressed();
119
120 #ifdef _WIN32
121
122 // This should only be necessary for MinGW, since it doesn't have a dwmapi.h. Add another #ifdef if you like.
123 extern "C"
124 {
125 typedef HRESULT(WINAPI *t_DwmFlush)();
126 typedef HRESULT(WINAPI *t_DwmIsCompositionEnabled)(BOOL *pfEnabled);
127 }
128
129 void do_DwmFlush()
130 {
131 static HMODULE shell = LoadLibrary("dwmapi.dll");
132
133 if(!shell)
134 return;
135
136 static t_DwmFlush flush=reinterpret_cast<t_DwmFlush>(GetProcAddress(shell, "DwmFlush"));
137 static t_DwmIsCompositionEnabled isEnabled=reinterpret_cast<t_DwmIsCompositionEnabled>(GetProcAddress(shell, "DwmIsCompositionEnabled"));
138
139 BOOL enabled;
140 isEnabled(&enabled);
141
142 if(isEnabled)
143 flush();
144 }
145
146 #endif // _WIN32
147
148 83751 bool flash_reduction_enabled(bool check_qr)
149 {
150
4/4
✓ Branch 0 taken 81530 times.
✓ Branch 1 taken 2221 times.
✓ Branch 2 taken 81074 times.
✓ Branch 3 taken 83295 times.
83751 return (check_qr && get_qr(qr_EPILEPSY)) || epilepsyFlashReduction || replay_is_debug();
151 }
152
153 // Dialogue largening
154 void large_dialog(DIALOG *d)
155 {
156 large_dialog(d, 1.5);
157 }
158
159 void large_dialog(DIALOG *d, float RESIZE_AMT)
160 {
161 if(!d[0].d1)
162 {
163 d[0].d1 = 1;
164 int32_t oldwidth = d[0].w;
165 int32_t oldheight = d[0].h;
166 int32_t oldx = d[0].x;
167 int32_t oldy = d[0].y;
168 d[0].x -= int32_t(d[0].w/RESIZE_AMT);
169 d[0].y -= int32_t(d[0].h/RESIZE_AMT);
170 d[0].w = int32_t(d[0].w*RESIZE_AMT);
171 d[0].h = int32_t(d[0].h*RESIZE_AMT);
172
173 for(int32_t i=1; d[i].proc !=NULL; i++)
174 {
175 // Place elements horizontally
176 double xpc = ((double)(d[i].x - oldx) / (double)oldwidth);
177 d[i].x = int32_t(d[0].x + (xpc*d[0].w));
178
179 if(d[i].proc != d_stringloader)
180 {
181 if(d[i].proc==d_bitmap_proc)
182 {
183 d[i].w *= 2;
184 }
185 else d[i].w = int32_t(d[i].w*RESIZE_AMT);
186 }
187
188 // Place elements vertically
189 double ypc = ((double)(d[i].y - oldy) / (double)oldheight);
190 d[i].y = int32_t(d[0].y + (ypc*d[0].h));
191
192 // Vertically resize elements
193 if(d[i].proc == jwin_edit_proc || d[i].proc == jwin_check_proc || d[i].proc == jwin_checkfont_proc)
194 {
195 d[i].h = int32_t((double)d[i].h*1.5);
196 }
197 else if(d[i].proc == jwin_droplist_proc || d[i].proc == d_joylist_proc)
198 {
199 d[i].y += int32_t((double)d[i].h*0.25);
200 d[i].h = int32_t((double)d[i].h*1.25);
201 }
202 else if(d[i].proc==d_bitmap_proc)
203 {
204 d[i].h *= 2;
205 }
206 else d[i].h = int32_t(d[i].h*RESIZE_AMT);
207
208 // Fix frames
209 if(d[i].proc == jwin_frame_proc)
210 {
211 d[i].x++;
212 d[i].y++;
213 d[i].w-=4;
214 d[i].h-=4;
215 }
216 }
217 }
218
219 for(int32_t i=1; d[i].proc!=NULL; i++)
220 {
221 if(d[i].proc==jwin_slider_proc)
222 continue;
223
224 // Bigger font
225 bool bigfontproc = (d[i].proc != d_midilist_proc && d[i].proc != jwin_droplist_proc && d[i].proc != jwin_abclist_proc && d[i].proc != jwin_list_proc && d[i].proc != d_joylist_proc);
226
227 if(!d[i].dp2 && bigfontproc)
228 {
229 d[i].dp2 = get_zc_font(font_lfont_l);
230 }
231 else if(!bigfontproc)
232 {
233 ((ListData *)d[i].dp)->font = &a4fonts[font_lfont_l];
234 }
235
236 // Make checkboxes work
237 if(d[i].proc == jwin_check_proc)
238 d[i].proc = jwin_checkfont_proc;
239 else if(d[i].proc == jwin_radio_proc)
240 d[i].proc = jwin_radiofont_proc;
241 }
242
243 jwin_center_dialog(d);
244 }
245
246
247 /**********************************/
248 /******** System functions ********/
249 /**********************************/
250
251 static char cfg_sect[] = "zeldadx"; //We need to rename this.
252 static char ctrl_sect[] = "Controls";
253 static char sfx_sect[] = "Volume";
254
255 int32_t d_dummy_proc(int32_t,DIALOG *,int32_t)
256 {
257 return D_O_K;
258 }
259
260 bool is_reserved_key(int c)
261 {
262 switch(c)
263 {
264 case KEY_ESC:
265 return true;
266 }
267 return false;
268 }
269 bool is_reserved_keycombo(int c, int modflag)
270 {
271 if(c==KEY_F4 && (modflag&KB_ALT_FLAG))
272 return true;
273 return false;
274 }
275 bool checkcheat(Cheat cheat)
276 {
277 if(cheatkeys[cheat][0] && zc_readkey(cheatkeys[cheat][0]))
278 return true; //Main key pressed
279 if(cheatkeys[cheat][1] && zc_readkey(cheatkeys[cheat][1]))
280 return true; //Alt key pressed
281 return false;
282 }
283 116 void load_default_cheatkeys()
284 {
285 116 memset(cheatkeys, 0, sizeof(cheatkeys));
286 116 cheatkeys[Cheat::Life][0] = KEY_H;
287 116 cheatkeys[Cheat::Life][1] = KEY_ASTERISK;
288 116 cheatkeys[Cheat::Magic][0] = KEY_M;
289 116 cheatkeys[Cheat::Magic][1] = KEY_SLASH_PAD;
290 116 cheatkeys[Cheat::Rupies][0] = KEY_R;
291 116 cheatkeys[Cheat::Bombs][0] = KEY_B;
292 116 cheatkeys[Cheat::Arrows][0] = KEY_A;
293 116 cheatkeys[Cheat::Clock][0] = KEY_I;
294 116 cheatkeys[Cheat::Walls][0] = KEY_F11;
295 116 cheatkeys[Cheat::Fast][0] = KEY_Q;
296 116 cheatkeys[Cheat::Light][0] = KEY_L;
297 116 cheatkeys[Cheat::IgnoreSideView][0] = KEY_V;
298 116 cheatkeys[Cheat::Kill][0] = KEY_K;
299 116 cheatkeys[Cheat::GoTo][0] = KEY_G;
300 116 cheatkeys[Cheat::TrigSecrets][0] = KEY_S;
301 116 cheatkeys[Cheat::ShowL0][0] = KEY_0;
302 116 cheatkeys[Cheat::ShowL1][0] = KEY_1;
303 116 cheatkeys[Cheat::ShowL2][0] = KEY_2;
304 116 cheatkeys[Cheat::ShowL3][0] = KEY_3;
305 116 cheatkeys[Cheat::ShowL4][0] = KEY_4;
306 116 cheatkeys[Cheat::ShowL5][0] = KEY_5;
307 116 cheatkeys[Cheat::ShowL6][0] = KEY_6;
308 116 cheatkeys[Cheat::ShowFFC][0] = KEY_7;
309 116 cheatkeys[Cheat::ShowSprites][0] = KEY_8;
310 116 cheatkeys[Cheat::ShowWalkability][0] = KEY_W;
311 116 cheatkeys[Cheat::ShowEffects][0] = KEY_E;
312 116 cheatkeys[Cheat::ShowOverhead][0] = KEY_O;
313 116 cheatkeys[Cheat::ShowPushblock][0] = KEY_P;
314 116 cheatkeys[Cheat::ShowHitbox][0] = KEY_C;
315 116 cheatkeys[Cheat::ShowFFCScripts][0] = KEY_F;
316 116 }
317 116 void load_game_configs()
318 {
319 116 strcpy(moduledata.module_name,zc_get_config("ZCMODULE",qst_module_name,"classic.zmod"));
320 116 joystick_index = zc_get_config(ctrl_sect,"joystick_index",0);
321 116 js_stick_1_x_stick = zc_get_config(ctrl_sect,"js_stick_1_x_stick",0);
322 116 js_stick_1_x_axis = zc_get_config(ctrl_sect,"js_stick_1_x_axis",0);
323 116 js_stick_1_x_offset = zc_get_config(ctrl_sect,"js_stick_1_x_offset",0) ? 128 : 0;
324 116 js_stick_1_y_stick = zc_get_config(ctrl_sect,"js_stick_1_y_stick",0);
325 116 js_stick_1_y_axis = zc_get_config(ctrl_sect,"js_stick_1_y_axis",1);
326 116 js_stick_1_y_offset = zc_get_config(ctrl_sect,"js_stick_1_y_offset",0) ? 128 : 0;
327 116 js_stick_2_x_stick = zc_get_config(ctrl_sect,"js_stick_2_x_stick",1);
328 116 js_stick_2_x_axis = zc_get_config(ctrl_sect,"js_stick_2_x_axis",0);
329 116 js_stick_2_x_offset = zc_get_config(ctrl_sect,"js_stick_2_x_offset",0) ? 128 : 0;
330 116 js_stick_2_y_stick = zc_get_config(ctrl_sect,"js_stick_2_y_stick",1);
331 116 js_stick_2_y_axis = zc_get_config(ctrl_sect,"js_stick_2_y_axis",1);
332 116 js_stick_2_y_offset = zc_get_config(ctrl_sect,"js_stick_2_y_offset",0) ? 128 : 0;
333 116 analog_movement = (zc_get_config(ctrl_sect,"analog_movement",1));
334
335 //cheat modifier keya
336 116 cheat_modifier_keys[0] = zc_get_config(ctrl_sect,"key_cheatmod_a1",KEY_ZC_LCONTROL);
337 116 cheat_modifier_keys[1] = zc_get_config(ctrl_sect,"key_cheatmod_a2",0);
338 116 cheat_modifier_keys[2] = zc_get_config(ctrl_sect,"key_cheatmod_b1",KEY_ZC_RCONTROL);
339 116 cheat_modifier_keys[3] = zc_get_config(ctrl_sect,"key_cheatmod_b2",0);
340
341 //cheat keys
342 116 load_default_cheatkeys();
343 char buf[256];
344
2/2
✓ Branch 0 taken 4060 times.
✓ Branch 1 taken 116 times.
4176 for(size_t q = 1; q < Cheat::Last; ++q)
345 {
346
1/2
✓ Branch 0 taken 4060 times.
✗ Branch 1 not taken.
4060 if(!bindable_cheat((Cheat)q)) continue;
347 4060 std::string cheatname = cheat_to_string((Cheat)q);
348
1/2
✓ Branch 0 taken 4060 times.
✗ Branch 1 not taken.
4060 util::lowerstr(cheatname);
349 4060 sprintf(buf, "key_cheat_%s_main", cheatname.c_str());
350
1/2
✓ Branch 0 taken 4060 times.
✗ Branch 1 not taken.
4060 cheatkeys[q][0] = zc_get_config(ctrl_sect,buf,cheatkeys[q][0]);
351 4060 sprintf(buf, "key_cheat_%s_alt", cheatname.c_str());
352
1/2
✓ Branch 0 taken 4060 times.
✗ Branch 1 not taken.
4060 cheatkeys[q][1] = zc_get_config(ctrl_sect,buf,cheatkeys[q][1]);
353 4060 }
354
355
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if((uint32_t)joystick_index >= MAX_JOYSTICKS)
356 joystick_index = 0;
357
358 116 Akey = zc_get_config(ctrl_sect,"key_a",KEY_Z);
359 116 Bkey = zc_get_config(ctrl_sect,"key_b",KEY_X);
360 116 Skey = zc_get_config(ctrl_sect,"key_s",KEY_ENTER);
361 116 Lkey = zc_get_config(ctrl_sect,"key_l",KEY_Q);
362 116 Rkey = zc_get_config(ctrl_sect,"key_r",KEY_W);
363 116 Pkey = zc_get_config(ctrl_sect,"key_p",KEY_SPACE);
364 116 Exkey1 = zc_get_config(ctrl_sect,"key_ex1",KEY_A);
365 116 Exkey2 = zc_get_config(ctrl_sect,"key_ex2",KEY_S);
366 116 Exkey3 = zc_get_config(ctrl_sect,"key_ex3",KEY_D);
367 116 Exkey4 = zc_get_config(ctrl_sect,"key_ex4",KEY_C);
368
369 116 DUkey = zc_get_config(ctrl_sect,"key_up", KEY_UP);
370 116 DDkey = zc_get_config(ctrl_sect,"key_down", KEY_DOWN);
371 116 DLkey = zc_get_config(ctrl_sect,"key_left", KEY_LEFT);
372 116 DRkey = zc_get_config(ctrl_sect,"key_right",KEY_RIGHT);
373
374 116 Abtn = zc_get_config(ctrl_sect,"btn_a",2);
375 116 Bbtn = zc_get_config(ctrl_sect,"btn_b",1);
376 116 Sbtn = zc_get_config(ctrl_sect,"btn_s",10);
377 116 Mbtn = zc_get_config(ctrl_sect,"btn_m",9);
378 116 Lbtn = zc_get_config(ctrl_sect,"btn_l",5);
379 116 Rbtn = zc_get_config(ctrl_sect,"btn_r",6);
380 116 Pbtn = zc_get_config(ctrl_sect,"btn_p",12);
381 116 Exbtn1 = zc_get_config(ctrl_sect,"btn_ex1",7);
382 116 Exbtn2 = zc_get_config(ctrl_sect,"btn_ex2",8);
383 116 Exbtn3 = zc_get_config(ctrl_sect,"btn_ex3",4);
384 116 Exbtn4 = zc_get_config(ctrl_sect,"btn_ex4",3);
385
386 116 DUbtn = zc_get_config(ctrl_sect,"btn_up",13);
387 116 DDbtn = zc_get_config(ctrl_sect,"btn_down",14);
388 116 DLbtn = zc_get_config(ctrl_sect,"btn_left",15);
389 116 DRbtn = zc_get_config(ctrl_sect,"btn_right",16);
390
391 116 epilepsyFlashReduction = zc_get_config(cfg_sect,"epilepsy_flash_reduction",0);
392
393 116 digi_volume = zc_get_config(sfx_sect,"digi",248);
394 116 midi_volume = zc_get_config(sfx_sect,"midi",255);
395 116 sfx_volume = zc_get_config(sfx_sect,"sfx",248);
396 116 emusic_volume = zc_get_config(sfx_sect,"emusic",248);
397 116 pan_style = zc_get_config(sfx_sect,"pan",1);
398 // 1 <= zcmusic_bufsz <= 128
399 116 zcmusic_bufsz = vbound(zc_get_config(sfx_sect,"zcmusic_bufsz",64),1,128);
400 116 volkeys = zc_get_config(sfx_sect,"volkeys",0)!=0;
401 116 zc_vsync = zc_get_config(cfg_sect,"vsync",0);
402 116 Throttlefps = zc_get_config(cfg_sect,"throttlefps",1)!=0;
403 116 TransLayers = zc_get_config(cfg_sect,"translayers",1)!=0;
404 116 SnapshotFormat = zc_get_config(cfg_sect,"snapshot_format",3);
405 116 NameEntryMode = zc_get_config(cfg_sect,"name_entry_mode",0);
406 #ifdef __EMSCRIPTEN__
407 if (em_is_mobile()) NameEntryMode = 2;
408 #endif
409 116 ShowFPS = zc_get_config(cfg_sect,"showfps",0)!=0;
410 116 NESquit = zc_get_config(cfg_sect,"fastquit",0)!=0;
411 116 ClickToFreeze = zc_get_config(cfg_sect,"clicktofreeze",1)!=0;
412 116 abc_patternmatch = zc_get_config(cfg_sect, "lister_pattern_matching", 1);
413 116 pause_in_background = zc_get_config(cfg_sect, "pause_in_background", 0);
414
415 //default - scale x2, 640 x 480
416 116 window_width = resx = zc_get_config(cfg_sect,"window_width",640);
417 116 window_height = resy = zc_get_config(cfg_sect,"window_height",480);
418 116 SaveDragResize = zc_get_config(cfg_sect,"save_drag_resize",0)!=0;
419 116 DragAspect = zc_get_config(cfg_sect,"drag_aspect",0)!=0;
420 116 SaveWinPos = zc_get_config(cfg_sect,"save_window_position",0)!=0;
421 116 scaleForceInteger = zc_get_config("zeldadx","scaling_force_integer",1)!=0;
422 116 stretchGame = zc_get_config("zeldadx","stretch_game_area",0)!=0;
423
424 116 loadlast = zc_get_config(cfg_sect,"load_last",0);
425
426 116 fullscreen = zc_get_config(cfg_sect,"fullscreen",0);
427
428 116 zc_color_depth = (byte) zc_get_config(cfg_sect,"color_depth",8);
429
430 116 forceExit = (byte) zc_get_config(cfg_sect,"force_exit",0);
431 116 info_opacity = zc_get_config("zc","debug_info_opacity",255);
432 #ifdef _WIN32
433 zasm_debugger = (byte) zc_get_config("CONSOLE","print_ZASM",0);
434 zscript_debugger = (byte) zc_get_config("CONSOLE","ZScript_Debugger",0);
435 //use_win7_keyboard_fix = (byte) zc_get_config(cfg_sect,"use_win7_key_fix",0);
436 use_win32_proc = (byte) zc_get_config(cfg_sect,"zc_win_proc_fix",0); //buggy
437
438 // This one's for Aero
439 use_dwm_flush = (byte) zc_get_config("zeldadx","use_dwm_flush",0);
440
441 monochrome_console = (byte) zc_get_config("CONSOLE","monochrome_debuggers",0);
442 #else //UNIX
443 116 zasm_debugger = (byte) zc_get_config("CONSOLE","print_ZASM",0);
444 116 zscript_debugger = (byte) zc_get_config("CONSOLE","ZScript_Debugger",0);
445 116 monochrome_console = (byte) zc_get_config("CONSOLE","monochrome_debuggers",0);
446 #endif
447 116 clearConsoleOnLoad = zc_get_config("CONSOLE","clear_console_on_load",1)!=0;
448 116 clearConsoleOnReload = zc_get_config("CONSOLE","clear_console_on_reload",0)!=0;
449
450 116 strcpy(qstdir,zc_get_config(cfg_sect,qst_dir_name,""));
451
452
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(strlen(qstdir)==0)
453 {
454 116 getcwd(qstdir,2048);
455 116 fix_filename_case(qstdir);
456 116 fix_filename_slashes(qstdir);
457 116 put_backslash(qstdir);
458 116 }
459 else
460 {
461 chop_path(qstdir);
462 }
463
464 116 strcpy(qstpath,qstdir); //qstpath is the local (for this run of ZC) quest path, qstdir is the universal quest dir.
465 116 ss_enable = zc_get_config(cfg_sect,"ss_enable",1) ? 1 : 0;
466 116 ss_after = vbound(zc_get_config(cfg_sect,"ss_after",14), 0, 14);
467 116 ss_speed = vbound(zc_get_config(cfg_sect,"ss_speed",2), 0, 6);
468 116 ss_density = vbound(zc_get_config(cfg_sect,"ss_density",3), 0, 6);
469 116 heart_beep = zc_get_config(cfg_sect,"heart_beep",1)!=0;
470 //gui_colorset = zc_get_config(cfg_sect,"gui_colorset",0);
471 116 sfxdat = zc_get_config(cfg_sect,"use_sfx_dat",1);
472 116 fullscreen = zc_get_config(cfg_sect,"fullscreen",0);
473 116 use_save_indicator = zc_get_config(cfg_sect,"save_indicator",0);
474 116 zc_192b163_warp_compatibility = zc_get_config(cfg_sect,"zc_192b163_warp_compatibility",0);
475 116 }
476
477 void save_control_configs(bool kb)
478 {
479 if(kb)
480 {
481 zc_set_config(ctrl_sect,"key_cheatmod_a1",cheat_modifier_keys[0]);
482 zc_set_config(ctrl_sect,"key_cheatmod_a2",cheat_modifier_keys[1]);
483 zc_set_config(ctrl_sect,"key_cheatmod_b1",cheat_modifier_keys[2]);
484 zc_set_config(ctrl_sect,"key_cheatmod_b2",cheat_modifier_keys[3]);
485
486 if (!replay_is_replaying())
487 {
488 zc_set_config(ctrl_sect,"key_a",Akey);
489 zc_set_config(ctrl_sect,"key_b",Bkey);
490 zc_set_config(ctrl_sect,"key_s",Skey);
491 zc_set_config(ctrl_sect,"key_l",Lkey);
492 zc_set_config(ctrl_sect,"key_r",Rkey);
493 zc_set_config(ctrl_sect,"key_p",Pkey);
494 zc_set_config(ctrl_sect,"key_ex1",Exkey1);
495 zc_set_config(ctrl_sect,"key_ex2",Exkey2);
496 zc_set_config(ctrl_sect,"key_ex3",Exkey3);
497 zc_set_config(ctrl_sect,"key_ex4",Exkey4);
498 zc_set_config(ctrl_sect,"key_up", DUkey);
499 zc_set_config(ctrl_sect,"key_down", DDkey);
500 zc_set_config(ctrl_sect,"key_left", DLkey);
501 zc_set_config(ctrl_sect,"key_right",DRkey);
502 }
503 }
504 else
505 {
506 zc_set_config(ctrl_sect,"joystick_index",joystick_index);
507 zc_set_config(ctrl_sect,"js_stick_1_x_stick",js_stick_1_x_stick);
508 zc_set_config(ctrl_sect,"js_stick_1_x_axis",js_stick_1_x_axis);
509 zc_set_config(ctrl_sect,"js_stick_1_x_offset",js_stick_1_x_offset ? 1 : 0);
510 zc_set_config(ctrl_sect,"js_stick_1_y_stick",js_stick_1_y_stick);
511 zc_set_config(ctrl_sect,"js_stick_1_y_axis",js_stick_1_y_axis);
512 zc_set_config(ctrl_sect,"js_stick_1_y_offset",js_stick_1_y_offset ? 1 : 0);
513 zc_set_config(ctrl_sect,"js_stick_2_x_stick",js_stick_2_x_stick);
514 zc_set_config(ctrl_sect,"js_stick_2_x_axis",js_stick_2_x_axis);
515 zc_set_config(ctrl_sect,"js_stick_2_x_offset",js_stick_2_x_offset ? 1 : 0);
516 zc_set_config(ctrl_sect,"js_stick_2_y_stick",js_stick_2_y_stick);
517 zc_set_config(ctrl_sect,"js_stick_2_y_axis",js_stick_2_y_axis);
518 zc_set_config(ctrl_sect,"js_stick_2_y_offset",js_stick_2_y_offset ? 1 : 0);
519 zc_set_config(ctrl_sect,"analog_movement",analog_movement);
520
521 zc_set_config(ctrl_sect,"btn_a",Abtn);
522 zc_set_config(ctrl_sect,"btn_b",Bbtn);
523 zc_set_config(ctrl_sect,"btn_s",Sbtn);
524 zc_set_config(ctrl_sect,"btn_m",Mbtn);
525 zc_set_config(ctrl_sect,"btn_l",Lbtn);
526 zc_set_config(ctrl_sect,"btn_r",Rbtn);
527 zc_set_config(ctrl_sect,"btn_p",Pbtn);
528 zc_set_config(ctrl_sect,"btn_ex1",Exbtn1);
529 zc_set_config(ctrl_sect,"btn_ex2",Exbtn2);
530 zc_set_config(ctrl_sect,"btn_ex3",Exbtn3);
531 zc_set_config(ctrl_sect,"btn_ex4",Exbtn4);
532
533 zc_set_config(ctrl_sect,"btn_up",DUbtn);
534 zc_set_config(ctrl_sect,"btn_down",DDbtn);
535 zc_set_config(ctrl_sect,"btn_left",DLbtn);
536 zc_set_config(ctrl_sect,"btn_right",DRbtn);
537 }
538 }
539
540 void save_cheatkeys()
541 {
542 char buf[256];
543 for(size_t q = 1; q < Cheat::Last; ++q)
544 {
545 if(!bindable_cheat((Cheat)q)) continue;
546 std::string cheatname = cheat_to_string((Cheat)q);
547 util::lowerstr(cheatname);
548 sprintf(buf, "key_cheat_%s_main", cheatname.c_str());
549 zc_set_config(ctrl_sect,buf,cheatkeys[q][0]);
550 sprintf(buf, "key_cheat_%s_alt", cheatname.c_str());
551 if(cheatkeys[q][1])
552 zc_set_config(ctrl_sect,buf,cheatkeys[q][1]);
553 else zc_set_config(ctrl_sect,buf,(char*)nullptr);
554 }
555 }
556
557 void save_game_configs()
558 {
559 packfile_password("");
560
561 zc_set_config("ZCMODULE",qst_module_name,moduledata.module_name);
562
563 if (all_get_display() && !all_get_fullscreen_flag()&& SaveWinPos)
564 {
565 int o_window_x, o_window_y;
566 al_get_window_position(all_get_display(), &o_window_x, &o_window_y);
567 zc_set_config(cfg_sect,"window_x",o_window_x);
568 zc_set_config(cfg_sect,"window_y",o_window_y);
569 }
570
571 if (all_get_display() && !all_get_fullscreen_flag() && SaveDragResize)
572 {
573 double monitor_scale = zc_get_monitor_scale();
574 window_width = al_get_display_width(all_get_display()) / monitor_scale;
575 window_height = al_get_display_height(all_get_display()) / monitor_scale;
576 zc_set_config(cfg_sect,"window_width",window_width);
577 zc_set_config(cfg_sect,"window_height",window_height);
578 }
579
580 zc_set_config(cfg_sect,"load_last",loadlast);
581 chop_path(qstdir);
582 zc_set_config(cfg_sect,qst_dir_name,qstdir);
583 zc_set_config(cfg_sect,"use_sfx_dat",sfxdat);
584
585 flush_config_file();
586 #ifdef __EMSCRIPTEN__
587 em_sync_fs();
588 #endif
589 }
590
591 //----------------------------------------------------------------
592
593 // Timers
594
595 29047 void fps_callback()
596 {
597 29047 lastfps=framecnt;
598 29047 dword tempsecs = fps_secs;
599 29047 ++tempsecs;
600 //avgfps=((long double)avgfps*fps_secs+lastfps)/(++fps_secs); // DJGPP doesn't like this
601 29047 avgfps=((long double)avgfps*fps_secs+lastfps)/(tempsecs);
602 29047 ++fps_secs;
603 29047 framecnt=0;
604 29047 }
605
606 END_OF_FUNCTION(fps_callback)
607
608 116 int32_t Z_init_timers()
609 {
610 static bool didit = false;
611 const static char *err_str = "Couldn't allocate timer";
612 116 err_str = err_str; //Unused variable warning
613
614
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(didit)
615 return 1;
616
617 116 didit = true;
618
619 LOCK_VARIABLE(lastfps);
620 LOCK_VARIABLE(framecnt);
621 LOCK_FUNCTION(fps_callback);
622
623
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if(install_int_ex(fps_callback,SECS_TO_TIMER(1)))
624 return 0;
625
626 116 return 1;
627 116 }
628
629 void Z_remove_timers()
630 {
631 remove_int(fps_callback);
632 }
633
634 //----------------------------------------------------------------
635
636 void go()
637 {
638 blit(screen,tmp_scr,scrx,scry,0,0,screen->w,screen->h);
639 }
640
641 void comeback()
642 {
643 blit(tmp_scr,screen,0,0,scrx,scry,screen->w,screen->h);
644 }
645
646 void dump_pal(BITMAP *dest)
647 {
648 for(int32_t i=0; i<256; i++)
649 rectfill(dest,(i&63)<<2,(i&0xFC0)>>4,((i&63)<<2)+3,((i&0xFC0)>>4)+3,i);
650 }
651
652 //----------------------------------------------------------------
653
654 int game_mouse_index = ZCM_BLANK;
655 static bool system_mouse = false;
656 28 bool sys_mouse()
657 {
658 28 system_mouse = true;
659 28 return MouseSprite::set(ZCM_NORMAL);
660 }
661 559 bool game_mouse()
662 {
663 559 system_mouse = false;
664 559 return MouseSprite::set(game_mouse_index);
665 }
666 void custom_mouse(BITMAP* bmp, int fx, int fy, bool sys_recolor, bool user_scale)
667 {
668 if(!bmp)
669 return;
670 float scale = vbound(zc_get_config("zeldadx","cursor_scale_large",1.5),1.0,5.0);
671 int scaledw = bmp->w*scale, scaledh = bmp->h*scale;
672 if(bmp->w == scaledw && bmp->h == scaledh)
673 user_scale = false;
674 if(user_scale || sys_recolor)
675 {
676 if(!user_scale) scale = 1;
677 BITMAP* tmpbmp = create_bitmap_ex(8,bmp->w*scale,bmp->h*scale);
678 if(user_scale)
679 stretch_blit(bmp, tmpbmp, 0, 0, bmp->w, bmp->h, 0, 0, tmpbmp->w, tmpbmp->h);
680 else
681 blit(bmp, tmpbmp, 0, 0, 0, 0, bmp->w, bmp->h);
682 if(sys_recolor)
683 recolor_mouse(tmpbmp);
684 MouseSprite::assign(ZCM_CUSTOM, tmpbmp, fx*scale, fy*scale);
685 destroy_bitmap(tmpbmp);
686 }
687 else
688 {
689 MouseSprite::assign(ZCM_CUSTOM, bmp, fx, fy);
690 }
691 }
692
693 //Handles converting the mouse sprite from the .dat file
694 void recolor_mouse(BITMAP* bmp)
695 {
696 for(int32_t x = 0; x < bmp->w; ++x)
697 {
698 for(int32_t y = 0; y < bmp->h; ++y)
699 {
700 int32_t color = getpixel(bmp, x, y);
701 switch(color)
702 {
703 case dvc(1):
704 color = jwin_pal[jcCURSORMISC];
705 break;
706 case dvc(2):
707 color = jwin_pal[jcCURSOROUTLINE];
708 break;
709 case dvc(3):
710 color = jwin_pal[jcCURSORLIGHT];
711 break;
712 case dvc(5):
713 color = jwin_pal[jcCURSORDARK];
714 break;
715 default:
716 continue;
717 }
718 putpixel(bmp, x, y, color);
719 }
720 }
721 }
722 void load_mouse()
723 {
724 PALETTE pal;
725 BITMAP* cursor_bitmap = load_bitmap("assets/cursor.bmp", pal);
726 if (!cursor_bitmap)
727 Z_error_fatal("Missing required file %s\n", "assets/cursor.bmp");
728
729 enter_sys_pal();
730 MouseSprite::set(-1);
731 float scale = vbound(zc_get_config("zeldadx","cursor_scale_large",1.5),1.0,5.0);
732 int32_t sz = 16*scale;
733 for(int32_t j = 0; j < 1; ++j)
734 {
735 BITMAP* tmpbmp = create_bitmap_ex(8,16,16);
736 if(zcmouse[j])
737 destroy_bitmap(zcmouse[j]);
738 zcmouse[j] = create_bitmap_ex(8,sz,sz);
739 clear_bitmap(zcmouse[j]);
740 clear_bitmap(tmpbmp);
741 blit(cursor_bitmap,tmpbmp,1,j*17+1,0,0,16,16);
742 recolor_mouse(tmpbmp);
743 if(sz!=16)
744 stretch_blit(tmpbmp, zcmouse[j], 0, 0, 16, 16, 0, 0, sz, sz);
745 else
746 blit(tmpbmp, zcmouse[j], 0, 0, 0, 0, 16, 16);
747 destroy_bitmap(tmpbmp);
748 }
749 if(!hw_palette) hw_palette = &RAMpal;
750 zc_set_palette(*hw_palette);
751
752 BITMAP* blankmouse = create_bitmap_ex(8,16,16);
753 clear_bitmap(blankmouse);
754
755 MouseSprite::assign(ZCM_NORMAL, zcmouse[0], 1*scale, 1*scale);
756 MouseSprite::assign(ZCM_BLANK, blankmouse);
757 //Don't assign ZCM_CUSTOM. That'll be handled by scripts.
758
759 //Reload the mouse
760 if(system_mouse)
761 sys_mouse();
762 else game_mouse();
763
764 destroy_bitmap(blankmouse);
765 destroy_bitmap(cursor_bitmap);
766 exit_sys_pal();
767 }
768
769 // sets the video mode and initializes the palette and mouse sprite
770 116 bool game_vid_mode(int32_t mode,int32_t wait)
771 {
772
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if (is_headless())
773 116 return true;
774
775 if(set_gfx_mode(mode,resx,resy,0,0)!=0)
776 {
777 return false;
778 }
779
780 scrx = (resx-320)>>1;
781 scry = (resy-240)>>1;
782 for(int32_t q = 0; q < NUM_ZCMOUSE; ++q)
783 zcmouse[q] = NULL;
784 load_mouse();
785
786 for(int32_t i=240; i<256; i++)
787 RAMpal[i]=pal_gui[i];
788
789 zc_set_palette(RAMpal);
790 clear_to_color(screen,BLACK);
791
792 rest(wait);
793 return true;
794 116 }
795
796 8 void null_quest()
797 {
798 char qstdat_string[2048];
799 8 strcpy(qstdat_string, "modules/classic/default.qst");
800
801 #ifdef __EMSCRIPTEN__
802 // The quest template data file is not included because it's really big and isn't really needed
803 // for the player, except to initialize some graphics. Those same graphics exist in this quest file,
804 // which is much smaller.
805 strcpy(qstdat_string, "modules/classic/title_gfx.dat");
806 #endif
807
808 8 byte skip_flags[4] = { 0 };
809
810 8 loadquest(qstdat_string,&QHeader,&QMisc,tunes+ZC_MIDI_COUNT,false,skip_flags,0,false);
811 8 }
812
813 8 void init_NES_mode()
814 {
815 8 null_quest();
816 8 }
817
818 //----------------------------------------------------------------
819
820 qword trianglelines[16]=
821 {
822 0x0000000000000000ULL,
823 0xFD00000000000000ULL,
824 0xFDFD000000000000ULL,
825 0xFDFDFD0000000000ULL,
826 0xFDFDFDFD00000000ULL,
827 0xFDFDFDFDFD000000ULL,
828 0xFDFDFDFDFDFD0000ULL,
829 0xFDFDFDFDFDFDFD00ULL,
830 0xFDFDFDFDFDFDFDFDULL,
831 0x00FDFDFDFDFDFDFDULL,
832 0x0000FDFDFDFDFDFDULL,
833 0x000000FDFDFDFDFDULL,
834 0x00000000FDFDFDFDULL,
835 0x0000000000FDFDFDULL,
836 0x000000000000FDFDULL,
837 0x00000000000000FDULL,
838 };
839
840 word screen_triangles[28][32];
841 /*
842 qword triangles[4][16]= //[direction][value]
843 {
844 {
845 0x00000000, 0x10000000, 0x21000000, 0x32100000, 0x43210000, 0x54321000, 0x65432100, 0x76543210, 0x87654321, 0x88765432, 0x88876543, 0x88887654, 0x88888765, 0x88888876, 0x88888887, 0x88888888
846 },
847 {
848 0x00000000, 0xF0000000, 0xEF000000, 0xFDF00000, 0xCFDF0000, 0xBCFDF000, 0xABCFDF00, 0x9ABCFDF0, 0x89ABCFDF, 0x889ABCFD, 0x8889ABCD, 0x88889ABC, 0x888889AB, 0x8888889A, 0x88888889, 0x88888888
849 },
850 {
851 0x00000000, 0x00000001, 0x00000012, 0x00000123, 0x00001234, 0x00012345, 0x00123456, 0x01234567, 0x12345678, 0x23456788, 0x34567888, 0x45678888, 0x56788888, 0x67888888, 0x78888888, 0x88888888
852 },
853 {
854 0x00000000, 0x0000000F, 0x000000FE, 0x00000FED, 0x0000FEDC, 0x000FEDCB, 0x00FEDCBA, 0x0FEDCBA9, 0xFEDCBA98, 0xEDCBA988, 0xDCBA9888, 0xCBA98888, 0xBA988888, 0xA9888888, 0x98888888, 0x88888888
855 }
856 };
857 */
858
859
860 /*
861 byte triangles[4][16][8]= //[direction][value][line]
862 {
863 {
864 {
865 0, 0, 0, 0, 0, 0, 0, 0
866 },
867 {
868 1, 0, 0, 0, 0, 0, 0, 0
869 },
870 {
871 2, 1, 0, 0, 0, 0, 0, 0
872 },
873 {
874 3, 2, 1, 0, 0, 0, 0, 0
875 },
876 {
877 4, 3, 2, 1, 0, 0, 0, 0
878 },
879 {
880 5, 4, 3, 2, 1, 0, 0, 0
881 },
882 {
883 6, 5, 4, 3, 2, 1, 0, 0
884 },
885 {
886 7, 6, 5, 4, 3, 2, 1, 0
887 },
888 {
889 8, 7, 6, 5, 4, 3, 2, 1
890 },
891 {
892 8, 8, 7, 6, 5, 4, 3, 2
893 },
894 {
895 8, 8, 8, 7, 6, 5, 4, 3
896 },
897 {
898 8, 8, 8, 8, 7, 6, 5, 4
899 },
900 {
901 8, 8, 8, 8, 8, 7, 6, 5
902 },
903 {
904 8, 8, 8, 8, 8, 8, 7, 6
905 },
906 {
907 8, 8, 8, 8, 8, 8, 8, 7
908 },
909 {
910 8, 8, 8, 8, 8, 8, 8, 8
911 }
912 },
913 {
914 {
915 0, 0, 0, 0, 0, 0, 0, 0
916 },
917 {
918 15, 0, 0, 0, 0, 0, 0, 0
919 },
920 {
921 14, 15, 0, 0, 0, 0, 0, 0
922 },
923 {
924 13, 14, 15, 0, 0, 0, 0, 0
925 },
926 {
927 12, 13, 14, 15, 0, 0, 0, 0
928 },
929 {
930 11, 12, 13, 14, 15, 0, 0, 0
931 },
932 {
933 10, 11, 12, 13, 14, 15, 0, 0
934 },
935 {
936 9, 10, 11, 12, 13, 14, 15, 0
937 },
938 {
939 8, 9, 10, 11, 12, 13, 14, 15
940 },
941 {
942 8, 8, 9, 10, 11, 12, 13, 14
943 },
944 {
945 8, 8, 8, 9, 10, 11, 12, 13
946 },
947 {
948 8, 8, 8, 8, 9, 10, 11, 12
949 },
950 {
951 8, 8, 8, 8, 8, 9, 10, 11
952 },
953 {
954 8, 8, 8, 8, 8, 8, 9, 10
955 },
956 {
957 8, 8, 8, 8, 8, 8, 8, 9
958 },
959 {
960 8, 8, 8, 8, 8, 8, 8, 8
961 }
962 },
963 {
964 {
965 0, 0, 0, 0, 0, 0, 0, 0
966 },
967 {
968 0, 0, 0, 0, 0, 0, 0, 1
969 },
970 {
971 0, 0, 0, 0, 0, 0, 1, 2
972 },
973 {
974 0, 0, 0, 0, 0, 1, 2, 3
975 },
976 {
977 0, 0, 0, 0, 1, 2, 3, 4
978 },
979 {
980 0, 0, 0, 1, 2, 3, 4, 5
981 },
982 {
983 0, 0, 1, 2, 3, 4, 5, 6
984 },
985 {
986 0, 1, 2, 3, 4, 5, 6, 7
987 },
988 {
989 1, 2, 3, 4, 5, 6, 7, 8
990 },
991 {
992 2, 3, 4, 5, 6, 7, 8, 8
993 },
994 {
995 3, 4, 5, 6, 7, 8, 8, 8
996 },
997 {
998 4, 5, 6, 7, 8, 8, 8, 8
999 },
1000 {
1001 5, 6, 7, 8, 8, 8, 8, 8
1002 },
1003 {
1004 6, 7, 8, 8, 8, 8, 8, 8
1005 },
1006 {
1007 7, 8, 8, 8, 8, 8, 8, 8
1008 },
1009 {
1010 8, 8, 8, 8, 8, 8, 8, 8
1011 }
1012 },
1013 {
1014 {
1015 0, 0, 0, 0, 0, 0, 0, 0
1016 },
1017 {
1018 0, 0, 0, 0, 0, 0, 0, 15
1019 },
1020 {
1021 0, 0, 0, 0, 0, 0, 15, 14
1022 },
1023 {
1024 0, 0, 0, 0, 0, 15, 14, 13
1025 },
1026 {
1027 0, 0, 0, 0, 15, 14, 13, 12
1028 },
1029 {
1030 0, 0, 0, 15, 14, 13, 12, 11
1031 },
1032 {
1033 0, 0, 15, 14, 13, 12, 11, 10
1034 },
1035 {
1036 0, 15, 14, 13, 12, 11, 10, 9
1037 },
1038 {
1039 15, 14, 13, 12, 11, 10, 9, 8
1040 },
1041 {
1042 14, 13, 12, 11, 10, 9, 8, 8
1043 },
1044 {
1045 13, 12, 11, 10, 9, 8, 8, 8
1046 },
1047 {
1048 12, 11, 10, 9, 8, 8, 8, 8
1049 },
1050 {
1051 11, 10, 9, 8, 8, 8, 8, 8
1052 },
1053 {
1054 10, 9, 8, 8, 8, 8, 8, 8
1055 },
1056 {
1057 9, 8, 8, 8, 8, 8, 8, 8
1058 },
1059 {
1060 8, 8, 8, 8, 8, 8, 8, 8
1061 }
1062 }
1063 };
1064 */
1065
1066
1067
1068 /*
1069 for (int32_t blockrow=0; blockrow<30; ++i)
1070 {
1071 for (int32_t linerow=0; linerow<8; ++i)
1072 {
1073 qword *triangleline=(qword*)(tmp_scr->line[(blockrow*8+linerow)]);
1074 for (int32_t blockcolumn=0; blockcolumn<40; ++i)
1075 {
1076 triangleline=triangles[0][screen_triangles[blockrow][blockcolumn]][linerow];
1077 ++triangleline;
1078 }
1079 }
1080 }
1081 */
1082
1083 // the ULL suffixes are to prevent this warning:
1084 // warning: integer constant is too large for "int32_t" type
1085
1086 qword triangles[4][16][8]= //[direction][value][line]
1087 {
1088 {
1089 {
1090 0x0000000000000000ULL,
1091 0x0000000000000000ULL,
1092 0x0000000000000000ULL,
1093 0x0000000000000000ULL,
1094 0x0000000000000000ULL,
1095 0x0000000000000000ULL,
1096 0x0000000000000000ULL,
1097 0x0000000000000000ULL
1098 },
1099 {
1100 0xFD00000000000000ULL,
1101 0x0000000000000000ULL,
1102 0x0000000000000000ULL,
1103 0x0000000000000000ULL,
1104 0x0000000000000000ULL,
1105 0x0000000000000000ULL,
1106 0x0000000000000000ULL,
1107 0x0000000000000000ULL
1108 },
1109 {
1110 0xFDFD000000000000ULL,
1111 0xFD00000000000000ULL,
1112 0x0000000000000000ULL,
1113 0x0000000000000000ULL,
1114 0x0000000000000000ULL,
1115 0x0000000000000000ULL,
1116 0x0000000000000000ULL,
1117 0x0000000000000000ULL
1118 },
1119 {
1120 0xFDFDFD0000000000ULL,
1121 0xFDFD000000000000ULL,
1122 0xFD00000000000000ULL,
1123 0x0000000000000000ULL,
1124 0x0000000000000000ULL,
1125 0x0000000000000000ULL,
1126 0x0000000000000000ULL,
1127 0x0000000000000000ULL
1128 },
1129 {
1130 0xFDFDFDFD00000000ULL,
1131 0xFDFDFD0000000000ULL,
1132 0xFDFD000000000000ULL,
1133 0xFD00000000000000ULL,
1134 0x0000000000000000ULL,
1135 0x0000000000000000ULL,
1136 0x0000000000000000ULL,
1137 0x0000000000000000ULL
1138 },
1139 {
1140 0xFDFDFDFDFD000000ULL,
1141 0xFDFDFDFD00000000ULL,
1142 0xFDFDFD0000000000ULL,
1143 0xFDFD000000000000ULL,
1144 0xFD00000000000000ULL,
1145 0x0000000000000000ULL,
1146 0x0000000000000000ULL,
1147 0x0000000000000000ULL
1148 },
1149 {
1150 0xFDFDFDFDFDFD0000ULL,
1151 0xFDFDFDFDFD000000ULL,
1152 0xFDFDFDFD00000000ULL,
1153 0xFDFDFD0000000000ULL,
1154 0xFDFD000000000000ULL,
1155 0xFD00000000000000ULL,
1156 0x0000000000000000ULL,
1157 0x0000000000000000ULL
1158 },
1159 {
1160 0xFDFDFDFDFDFDFD00ULL,
1161 0xFDFDFDFDFDFD0000ULL,
1162 0xFDFDFDFDFD000000ULL,
1163 0xFDFDFDFD00000000ULL,
1164 0xFDFDFD0000000000ULL,
1165 0xFDFD000000000000ULL,
1166 0xFD00000000000000ULL,
1167 0x0000000000000000ULL
1168 },
1169 {
1170 0xFDFDFDFDFDFDFDFDULL,
1171 0xFDFDFDFDFDFDFD00ULL,
1172 0xFDFDFDFDFDFD0000ULL,
1173 0xFDFDFDFDFD000000ULL,
1174 0xFDFDFDFD00000000ULL,
1175 0xFDFDFD0000000000ULL,
1176 0xFDFD000000000000ULL,
1177 0xFD00000000000000ULL
1178 },
1179 {
1180 0xFDFDFDFDFDFDFDFDULL,
1181 0xFDFDFDFDFDFDFDFDULL,
1182 0xFDFDFDFDFDFDFD00ULL,
1183 0xFDFDFDFDFDFD0000ULL,
1184 0xFDFDFDFDFD000000ULL,
1185 0xFDFDFDFD00000000ULL,
1186 0xFDFDFD0000000000ULL,
1187 0xFDFD000000000000ULL
1188 },
1189 {
1190 0xFDFDFDFDFDFDFDFDULL,
1191 0xFDFDFDFDFDFDFDFDULL,
1192 0xFDFDFDFDFDFDFDFDULL,
1193 0xFDFDFDFDFDFDFD00ULL,
1194 0xFDFDFDFDFDFD0000ULL,
1195 0xFDFDFDFDFD000000ULL,
1196 0xFDFDFDFD00000000ULL,
1197 0xFDFDFD0000000000ULL
1198 },
1199 {
1200 0xFDFDFDFDFDFDFDFDULL,
1201 0xFDFDFDFDFDFDFDFDULL,
1202 0xFDFDFDFDFDFDFDFDULL,
1203 0xFDFDFDFDFDFDFDFDULL,
1204 0xFDFDFDFDFDFDFD00ULL,
1205 0xFDFDFDFDFDFD0000ULL,
1206 0xFDFDFDFDFD000000ULL,
1207 0xFDFDFDFD00000000ULL
1208 },
1209 {
1210 0xFDFDFDFDFDFDFDFDULL,
1211 0xFDFDFDFDFDFDFDFDULL,
1212 0xFDFDFDFDFDFDFDFDULL,
1213 0xFDFDFDFDFDFDFDFDULL,
1214 0xFDFDFDFDFDFDFDFDULL,
1215 0xFDFDFDFDFDFDFD00ULL,
1216 0xFDFDFDFDFDFD0000ULL,
1217 0xFDFDFDFDFD000000ULL
1218 },
1219 {
1220 0xFDFDFDFDFDFDFDFDULL,
1221 0xFDFDFDFDFDFDFDFDULL,
1222 0xFDFDFDFDFDFDFDFDULL,
1223 0xFDFDFDFDFDFDFDFDULL,
1224 0xFDFDFDFDFDFDFDFDULL,
1225 0xFDFDFDFDFDFDFDFDULL,
1226 0xFDFDFDFDFDFDFD00ULL,
1227 0xFDFDFDFDFDFD0000ULL
1228 },
1229 {
1230 0xFDFDFDFDFDFDFDFDULL,
1231 0xFDFDFDFDFDFDFDFDULL,
1232 0xFDFDFDFDFDFDFDFDULL,
1233 0xFDFDFDFDFDFDFDFDULL,
1234 0xFDFDFDFDFDFDFDFDULL,
1235 0xFDFDFDFDFDFDFDFDULL,
1236 0xFDFDFDFDFDFDFDFDULL,
1237 0xFDFDFDFDFDFDFD00ULL
1238 },
1239 {
1240 0xFDFDFDFDFDFDFDFDULL,
1241 0xFDFDFDFDFDFDFDFDULL,
1242 0xFDFDFDFDFDFDFDFDULL,
1243 0xFDFDFDFDFDFDFDFDULL,
1244 0xFDFDFDFDFDFDFDFDULL,
1245 0xFDFDFDFDFDFDFDFDULL,
1246 0xFDFDFDFDFDFDFDFDULL,
1247 0xFDFDFDFDFDFDFDFDULL
1248 }
1249 },
1250 {
1251 {
1252 0x0000000000000000ULL,
1253 0x0000000000000000ULL,
1254 0x0000000000000000ULL,
1255 0x0000000000000000ULL,
1256 0x0000000000000000ULL,
1257 0x0000000000000000ULL,
1258 0x0000000000000000ULL,
1259 0x0000000000000000ULL
1260 },
1261 {
1262 0x00000000000000FDULL,
1263 0x0000000000000000ULL,
1264 0x0000000000000000ULL,
1265 0x0000000000000000ULL,
1266 0x0000000000000000ULL,
1267 0x0000000000000000ULL,
1268 0x0000000000000000ULL,
1269 0x0000000000000000ULL
1270 },
1271 {
1272 0x000000000000FDFDULL,
1273 0x00000000000000FDULL,
1274 0x0000000000000000ULL,
1275 0x0000000000000000ULL,
1276 0x0000000000000000ULL,
1277 0x0000000000000000ULL,
1278 0x0000000000000000ULL,
1279 0x0000000000000000ULL
1280 },
1281 {
1282 0x0000000000FDFDFDULL,
1283 0x000000000000FDFDULL,
1284 0x00000000000000FDULL,
1285 0x0000000000000000ULL,
1286 0x0000000000000000ULL,
1287 0x0000000000000000ULL,
1288 0x0000000000000000ULL,
1289 0x0000000000000000ULL
1290 },
1291 {
1292 0x00000000FDFDFDFDULL,
1293 0x0000000000FDFDFDULL,
1294 0x000000000000FDFDULL,
1295 0x00000000000000FDULL,
1296 0x0000000000000000ULL,
1297 0x0000000000000000ULL,
1298 0x0000000000000000ULL,
1299 0x0000000000000000ULL
1300 },
1301 {
1302 0x000000FDFDFDFDFDULL,
1303 0x00000000FDFDFDFDULL,
1304 0x0000000000FDFDFDULL,
1305 0x000000000000FDFDULL,
1306 0x00000000000000FDULL,
1307 0x0000000000000000ULL,
1308 0x0000000000000000ULL,
1309 0x0000000000000000ULL
1310 },
1311 {
1312 0x0000FDFDFDFDFDFDULL,
1313 0x000000FDFDFDFDFDULL,
1314 0x00000000FDFDFDFDULL,
1315 0x0000000000FDFDFDULL,
1316 0x000000000000FDFDULL,
1317 0x00000000000000FDULL,
1318 0x0000000000000000ULL,
1319 0x0000000000000000ULL
1320 },
1321 {
1322 0x00FDFDFDFDFDFDFDULL,
1323 0x0000FDFDFDFDFDFDULL,
1324 0x000000FDFDFDFDFDULL,
1325 0x00000000FDFDFDFDULL,
1326 0x0000000000FDFDFDULL,
1327 0x000000000000FDFDULL,
1328 0x00000000000000FDULL,
1329 0x0000000000000000ULL
1330 },
1331 {
1332 0xFDFDFDFDFDFDFDFDULL,
1333 0x00FDFDFDFDFDFDFDULL,
1334 0x0000FDFDFDFDFDFDULL,
1335 0x000000FDFDFDFDFDULL,
1336 0x00000000FDFDFDFDULL,
1337 0x0000000000FDFDFDULL,
1338 0x000000000000FDFDULL,
1339 0x00000000000000FDULL
1340 },
1341 {
1342 0xFDFDFDFDFDFDFDFDULL,
1343 0xFDFDFDFDFDFDFDFDULL,
1344 0x00FDFDFDFDFDFDFDULL,
1345 0x0000FDFDFDFDFDFDULL,
1346 0x000000FDFDFDFDFDULL,
1347 0x00000000FDFDFDFDULL,
1348 0x0000000000FDFDFDULL,
1349 0x000000000000FDFDULL
1350 },
1351 {
1352 0xFDFDFDFDFDFDFDFDULL,
1353 0xFDFDFDFDFDFDFDFDULL,
1354 0xFDFDFDFDFDFDFDFDULL,
1355 0x00FDFDFDFDFDFDFDULL,
1356 0x0000FDFDFDFDFDFDULL,
1357 0x000000FDFDFDFDFDULL,
1358 0x00000000FDFDFDFDULL,
1359 0x0000000000FDFDFDULL
1360 },
1361 {
1362 0xFDFDFDFDFDFDFDFDULL,
1363 0xFDFDFDFDFDFDFDFDULL,
1364 0xFDFDFDFDFDFDFDFDULL,
1365 0xFDFDFDFDFDFDFDFDULL,
1366 0x00FDFDFDFDFDFDFDULL,
1367 0x0000FDFDFDFDFDFDULL,
1368 0x000000FDFDFDFDFDULL,
1369 0x00000000FDFDFDFDULL
1370 },
1371 {
1372 0xFDFDFDFDFDFDFDFDULL,
1373 0xFDFDFDFDFDFDFDFDULL,
1374 0xFDFDFDFDFDFDFDFDULL,
1375 0xFDFDFDFDFDFDFDFDULL,
1376 0xFDFDFDFDFDFDFDFDULL,
1377 0x00FDFDFDFDFDFDFDULL,
1378 0x0000FDFDFDFDFDFDULL,
1379 0x000000FDFDFDFDFDULL
1380 },
1381 {
1382 0xFDFDFDFDFDFDFDFDULL,
1383 0xFDFDFDFDFDFDFDFDULL,
1384 0xFDFDFDFDFDFDFDFDULL,
1385 0xFDFDFDFDFDFDFDFDULL,
1386 0xFDFDFDFDFDFDFDFDULL,
1387 0xFDFDFDFDFDFDFDFDULL,
1388 0x00FDFDFDFDFDFDFDULL,
1389 0x0000FDFDFDFDFDFDULL
1390 },
1391 {
1392 0xFDFDFDFDFDFDFDFDULL,
1393 0xFDFDFDFDFDFDFDFDULL,
1394 0xFDFDFDFDFDFDFDFDULL,
1395 0xFDFDFDFDFDFDFDFDULL,
1396 0xFDFDFDFDFDFDFDFDULL,
1397 0xFDFDFDFDFDFDFDFDULL,
1398 0xFDFDFDFDFDFDFDFDULL,
1399 0x00FDFDFDFDFDFDFDULL
1400 },
1401 {
1402 0xFDFDFDFDFDFDFDFDULL,
1403 0xFDFDFDFDFDFDFDFDULL,
1404 0xFDFDFDFDFDFDFDFDULL,
1405 0xFDFDFDFDFDFDFDFDULL,
1406 0xFDFDFDFDFDFDFDFDULL,
1407 0xFDFDFDFDFDFDFDFDULL,
1408 0xFDFDFDFDFDFDFDFDULL,
1409 0xFDFDFDFDFDFDFDFDULL
1410 }
1411 },
1412 {
1413 {
1414 0x0000000000000000ULL,
1415 0x0000000000000000ULL,
1416 0x0000000000000000ULL,
1417 0x0000000000000000ULL,
1418 0x0000000000000000ULL,
1419 0x0000000000000000ULL,
1420 0x0000000000000000ULL,
1421 0x0000000000000000ULL
1422 },
1423 {
1424 0x0000000000000000ULL,
1425 0x0000000000000000ULL,
1426 0x0000000000000000ULL,
1427 0x0000000000000000ULL,
1428 0x0000000000000000ULL,
1429 0x0000000000000000ULL,
1430 0x0000000000000000ULL,
1431 0xFD00000000000000ULL
1432 },
1433 {
1434 0x0000000000000000ULL,
1435 0x0000000000000000ULL,
1436 0x0000000000000000ULL,
1437 0x0000000000000000ULL,
1438 0x0000000000000000ULL,
1439 0x0000000000000000ULL,
1440 0xFD00000000000000ULL,
1441 0xFDFD000000000000ULL
1442 },
1443 {
1444 0x0000000000000000ULL,
1445 0x0000000000000000ULL,
1446 0x0000000000000000ULL,
1447 0x0000000000000000ULL,
1448 0x0000000000000000ULL,
1449 0xFD00000000000000ULL,
1450 0xFDFD000000000000ULL,
1451 0xFDFDFD0000000000ULL
1452 },
1453 {
1454 0x0000000000000000ULL,
1455 0x0000000000000000ULL,
1456 0x0000000000000000ULL,
1457 0x0000000000000000ULL,
1458 0xFD00000000000000ULL,
1459 0xFDFD000000000000ULL,
1460 0xFDFDFD0000000000ULL,
1461 0xFDFDFDFD00000000ULL
1462 },
1463 {
1464 0x0000000000000000ULL,
1465 0x0000000000000000ULL,
1466 0x0000000000000000ULL,
1467 0xFD00000000000000ULL,
1468 0xFDFD000000000000ULL,
1469 0xFDFDFD0000000000ULL,
1470 0xFDFDFDFD00000000ULL,
1471 0xFDFDFDFDFD000000ULL
1472 },
1473 {
1474 0x0000000000000000ULL,
1475 0x0000000000000000ULL,
1476 0xFD00000000000000ULL,
1477 0xFDFD000000000000ULL,
1478 0xFDFDFD0000000000ULL,
1479 0xFDFDFDFD00000000ULL,
1480 0xFDFDFDFDFD000000ULL,
1481 0xFDFDFDFDFDFD0000ULL
1482 },
1483 {
1484 0x0000000000000000ULL,
1485 0xFD00000000000000ULL,
1486 0xFDFD000000000000ULL,
1487 0xFDFDFD0000000000ULL,
1488 0xFDFDFDFD00000000ULL,
1489 0xFDFDFDFDFD000000ULL,
1490 0xFDFDFDFDFDFD0000ULL,
1491 0xFDFDFDFDFDFDFD00ULL
1492 },
1493 {
1494 0xFD00000000000000ULL,
1495 0xFDFD000000000000ULL,
1496 0xFDFDFD0000000000ULL,
1497 0xFDFDFDFD00000000ULL,
1498 0xFDFDFDFDFD000000ULL,
1499 0xFDFDFDFDFDFD0000ULL,
1500 0xFDFDFDFDFDFDFD00ULL,
1501 0xFDFDFDFDFDFDFDFDULL
1502 },
1503 {
1504 0xFDFD000000000000ULL,
1505 0xFDFDFD0000000000ULL,
1506 0xFDFDFDFD00000000ULL,
1507 0xFDFDFDFDFD000000ULL,
1508 0xFDFDFDFDFDFD0000ULL,
1509 0xFDFDFDFDFDFDFD00ULL,
1510 0xFDFDFDFDFDFDFDFDULL,
1511 0xFDFDFDFDFDFDFDFDULL
1512 },
1513 {
1514 0xFDFDFD0000000000ULL,
1515 0xFDFDFDFD00000000ULL,
1516 0xFDFDFDFDFD000000ULL,
1517 0xFDFDFDFDFDFD0000ULL,
1518 0xFDFDFDFDFDFDFD00ULL,
1519 0xFDFDFDFDFDFDFDFDULL,
1520 0xFDFDFDFDFDFDFDFDULL,
1521 0xFDFDFDFDFDFDFDFDULL
1522 },
1523 {
1524 0xFDFDFDFD00000000ULL,
1525 0xFDFDFDFDFD000000ULL,
1526 0xFDFDFDFDFDFD0000ULL,
1527 0xFDFDFDFDFDFDFD00ULL,
1528 0xFDFDFDFDFDFDFDFDULL,
1529 0xFDFDFDFDFDFDFDFDULL,
1530 0xFDFDFDFDFDFDFDFDULL,
1531 0xFDFDFDFDFDFDFDFDULL
1532 },
1533 {
1534 0xFDFDFDFDFD000000ULL,
1535 0xFDFDFDFDFDFD0000ULL,
1536 0xFDFDFDFDFDFDFD00ULL,
1537 0xFDFDFDFDFDFDFDFDULL,
1538 0xFDFDFDFDFDFDFDFDULL,
1539 0xFDFDFDFDFDFDFDFDULL,
1540 0xFDFDFDFDFDFDFDFDULL,
1541 0xFDFDFDFDFDFDFDFDULL
1542 },
1543 {
1544 0xFDFDFDFDFDFD0000ULL,
1545 0xFDFDFDFDFDFDFD00ULL,
1546 0xFDFDFDFDFDFDFDFDULL,
1547 0xFDFDFDFDFDFDFDFDULL,
1548 0xFDFDFDFDFDFDFDFDULL,
1549 0xFDFDFDFDFDFDFDFDULL,
1550 0xFDFDFDFDFDFDFDFDULL,
1551 0xFDFDFDFDFDFDFDFDULL
1552 },
1553 {
1554 0xFDFDFDFDFDFDFD00ULL,
1555 0xFDFDFDFDFDFDFDFDULL,
1556 0xFDFDFDFDFDFDFDFDULL,
1557 0xFDFDFDFDFDFDFDFDULL,
1558 0xFDFDFDFDFDFDFDFDULL,
1559 0xFDFDFDFDFDFDFDFDULL,
1560 0xFDFDFDFDFDFDFDFDULL,
1561 0xFDFDFDFDFDFDFDFDULL
1562 },
1563 {
1564 0xFDFDFDFDFDFDFDFDULL,
1565 0xFDFDFDFDFDFDFDFDULL,
1566 0xFDFDFDFDFDFDFDFDULL,
1567 0xFDFDFDFDFDFDFDFDULL,
1568 0xFDFDFDFDFDFDFDFDULL,
1569 0xFDFDFDFDFDFDFDFDULL,
1570 0xFDFDFDFDFDFDFDFDULL,
1571 0xFDFDFDFDFDFDFDFDULL
1572 }
1573 },
1574 {
1575 {
1576 0x0000000000000000ULL,
1577 0x0000000000000000ULL,
1578 0x0000000000000000ULL,
1579 0x0000000000000000ULL,
1580 0x0000000000000000ULL,
1581 0x0000000000000000ULL,
1582 0x0000000000000000ULL,
1583 0x0000000000000000ULL
1584 },
1585 {
1586 0x0000000000000000ULL,
1587 0x0000000000000000ULL,
1588 0x0000000000000000ULL,
1589 0x0000000000000000ULL,
1590 0x0000000000000000ULL,
1591 0x0000000000000000ULL,
1592 0x0000000000000000ULL,
1593 0x00000000000000FDULL
1594 },
1595 {
1596 0x0000000000000000ULL,
1597 0x0000000000000000ULL,
1598 0x0000000000000000ULL,
1599 0x0000000000000000ULL,
1600 0x0000000000000000ULL,
1601 0x0000000000000000ULL,
1602 0x00000000000000FDULL,
1603 0x000000000000FDFDULL
1604 },
1605 {
1606 0x0000000000000000ULL,
1607 0x0000000000000000ULL,
1608 0x0000000000000000ULL,
1609 0x0000000000000000ULL,
1610 0x0000000000000000ULL,
1611 0x00000000000000FDULL,
1612 0x000000000000FDFDULL,
1613 0x0000000000FDFDFDULL
1614 },
1615 {
1616 0x0000000000000000ULL,
1617 0x0000000000000000ULL,
1618 0x0000000000000000ULL,
1619 0x0000000000000000ULL,
1620 0x00000000000000FDULL,
1621 0x000000000000FDFDULL,
1622 0x0000000000FDFDFDULL,
1623 0x00000000FDFDFDFDULL
1624 },
1625 {
1626 0x0000000000000000ULL,
1627 0x0000000000000000ULL,
1628 0x0000000000000000ULL,
1629 0x00000000000000FDULL,
1630 0x000000000000FDFDULL,
1631 0x0000000000FDFDFDULL,
1632 0x00000000FDFDFDFDULL,
1633 0x000000FDFDFDFDFDULL
1634 },
1635 {
1636 0x0000000000000000ULL,
1637 0x0000000000000000ULL,
1638 0x00000000000000FDULL,
1639 0x000000000000FDFDULL,
1640 0x0000000000FDFDFDULL,
1641 0x00000000FDFDFDFDULL,
1642 0x000000FDFDFDFDFDULL,
1643 0x0000FDFDFDFDFDFDULL
1644 },
1645 {
1646 0x0000000000000000ULL,
1647 0x00000000000000FDULL,
1648 0x000000000000FDFDULL,
1649 0x0000000000FDFDFDULL,
1650 0x00000000FDFDFDFDULL,
1651 0x000000FDFDFDFDFDULL,
1652 0x0000FDFDFDFDFDFDULL,
1653 0x00FDFDFDFDFDFDFDULL
1654 },
1655 {
1656 0x00000000000000FDULL,
1657 0x000000000000FDFDULL,
1658 0x0000000000FDFDFDULL,
1659 0x00000000FDFDFDFDULL,
1660 0x000000FDFDFDFDFDULL,
1661 0x0000FDFDFDFDFDFDULL,
1662 0x00FDFDFDFDFDFDFDULL,
1663 0xFDFDFDFDFDFDFDFDULL
1664 },
1665 {
1666 0x000000000000FDFDULL,
1667 0x0000000000FDFDFDULL,
1668 0x00000000FDFDFDFDULL,
1669 0x000000FDFDFDFDFDULL,
1670 0x0000FDFDFDFDFDFDULL,
1671 0x00FDFDFDFDFDFDFDULL,
1672 0xFDFDFDFDFDFDFDFDULL,
1673 0xFDFDFDFDFDFDFDFDULL
1674 },
1675 {
1676 0x0000000000FDFDFDULL,
1677 0x00000000FDFDFDFDULL,
1678 0x000000FDFDFDFDFDULL,
1679 0x0000FDFDFDFDFDFDULL,
1680 0x00FDFDFDFDFDFDFDULL,
1681 0xFDFDFDFDFDFDFDFDULL,
1682 0xFDFDFDFDFDFDFDFDULL,
1683 0xFDFDFDFDFDFDFDFDULL
1684 },
1685 {
1686 0x00000000FDFDFDFDULL,
1687 0x000000FDFDFDFDFDULL,
1688 0x0000FDFDFDFDFDFDULL,
1689 0x00FDFDFDFDFDFDFDULL,
1690 0xFDFDFDFDFDFDFDFDULL,
1691 0xFDFDFDFDFDFDFDFDULL,
1692 0xFDFDFDFDFDFDFDFDULL,
1693 0xFDFDFDFDFDFDFDFDULL
1694 },
1695 {
1696 0x000000FDFDFDFDFDULL,
1697 0x0000FDFDFDFDFDFDULL,
1698 0x00FDFDFDFDFDFDFDULL,
1699 0xFDFDFDFDFDFDFDFDULL,
1700 0xFDFDFDFDFDFDFDFDULL,
1701 0xFDFDFDFDFDFDFDFDULL,
1702 0xFDFDFDFDFDFDFDFDULL,
1703 0xFDFDFDFDFDFDFDFDULL
1704 },
1705 {
1706 0x0000FDFDFDFDFDFDULL,
1707 0x00FDFDFDFDFDFDFDULL,
1708 0xFDFDFDFDFDFDFDFDULL,
1709 0xFDFDFDFDFDFDFDFDULL,
1710 0xFDFDFDFDFDFDFDFDULL,
1711 0xFDFDFDFDFDFDFDFDULL,
1712 0xFDFDFDFDFDFDFDFDULL,
1713 0xFDFDFDFDFDFDFDFDULL
1714 },
1715 {
1716 0x00FDFDFDFDFDFDFDULL,
1717 0xFDFDFDFDFDFDFDFDULL,
1718 0xFDFDFDFDFDFDFDFDULL,
1719 0xFDFDFDFDFDFDFDFDULL,
1720 0xFDFDFDFDFDFDFDFDULL,
1721 0xFDFDFDFDFDFDFDFDULL,
1722 0xFDFDFDFDFDFDFDFDULL,
1723 0xFDFDFDFDFDFDFDFDULL
1724 },
1725 {
1726 0xFDFDFDFDFDFDFDFDULL,
1727 0xFDFDFDFDFDFDFDFDULL,
1728 0xFDFDFDFDFDFDFDFDULL,
1729 0xFDFDFDFDFDFDFDFDULL,
1730 0xFDFDFDFDFDFDFDFDULL,
1731 0xFDFDFDFDFDFDFDFDULL,
1732 0xFDFDFDFDFDFDFDFDULL,
1733 0xFDFDFDFDFDFDFDFDULL
1734 }
1735 }
1736 };
1737
1738 int32_t black_opening_count=0;
1739 int32_t black_opening_x,black_opening_y;
1740 int32_t black_opening_shape;
1741
1742 1507 int32_t choose_opening_shape()
1743 {
1744 // First, count how many bits are set
1745 1507 int32_t numBits=0;
1746 int32_t bitCounter;
1747
1748
2/2
✓ Branch 0 taken 7535 times.
✓ Branch 1 taken 1507 times.
9042 for(int32_t i=0; i<bosMAX; i++)
1749 {
1750
2/2
✓ Branch 0 taken 5812 times.
✓ Branch 1 taken 1723 times.
7535 if(COOLSCROLL&(1<<i))
1751 1723 numBits++;
1752 7535 }
1753
1754 // Shouldn't happen...
1755
1/2
✓ Branch 0 taken 1507 times.
✗ Branch 1 not taken.
1507 if(numBits==0)
1756 return bosCIRCLE;
1757
1758 // Pick a bit
1759 1507 bitCounter=zc_rand()%numBits+1;
1760
1761
2/2
✓ Branch 0 taken 1992 times.
✓ Branch 1 taken 26 times.
2018 for(int32_t i=0; i<bosMAX; i++)
1762 {
1763 // If this bit is set, decrement the bit counter
1764
2/2
✓ Branch 0 taken 355 times.
✓ Branch 1 taken 1637 times.
1992 if(COOLSCROLL&(1<<i))
1765 1637 bitCounter--;
1766
1767 // When the counter hits 0, return a value based on
1768 // which bit it stopped on.
1769 // Reminder: enum {bosCIRCLE=0, bosOVAL, bosTRIANGLE, bosSMAS, bosFADEBLACK, bosMAX};
1770
2/2
✓ Branch 0 taken 1481 times.
✓ Branch 1 taken 511 times.
1992 if(bitCounter==0)
1771 1481 return i;
1772 511 }
1773
1774 // Shouldn't be necessary, but the compiler might complain, at least
1775 26 return bosCIRCLE;
1776 1507 }
1777
1778 396 void close_black_opening(int32_t x, int32_t y, bool wait, int32_t shape)
1779 {
1780
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 396 times.
396 black_opening_shape= (shape>-1 ? shape : choose_opening_shape());
1781
1782 396 int32_t w=256, h=224;
1783 396 int32_t blockrows=28, blockcolumns=32;
1784 396 int32_t xoffset=(x-(w/2))/8, yoffset=(y-(h/2))/8;
1785
1786
2/2
✓ Branch 0 taken 11088 times.
✓ Branch 1 taken 396 times.
11484 for(int32_t blockrow=0; blockrow<blockrows; ++blockrow) //30
1787 {
1788
2/2
✓ Branch 0 taken 354816 times.
✓ Branch 1 taken 11088 times.
365904 for(int32_t blockcolumn=0; blockcolumn<blockcolumns; ++blockcolumn) //40
1789 {
1790
2/2
✓ Branch 0 taken 188540 times.
✓ Branch 1 taken 166276 times.
354816 screen_triangles[blockrow][blockcolumn]=zc_max(abs(int32_t(double(blockcolumns-1)/2-blockcolumn+xoffset)),abs(int32_t(double(blockrows-1)/2-blockrow+yoffset)))|0x0100|((blockrow-yoffset<blockrows/2)?0:0x8000)|((blockcolumn-xoffset<blockcolumns/2)?0x4000:0);
1791 354816 }
1792 11088 }
1793
1794 396 black_opening_count = 66;
1795 396 black_opening_x = x;
1796 396 black_opening_y = y;
1797 396 lensclk = 0;
1798 //black_opening_shape=(black_opening_shape+1)%bosMAX;
1799
1800
1801
1/2
✓ Branch 0 taken 396 times.
✗ Branch 1 not taken.
396 if(black_opening_shape == bosFADEBLACK)
1802 {
1803 refreshTints();
1804 memcpy(tempblackpal, RAMpal, sizeof(RAMpal)); //Store palette in temp palette for fade effect
1805 }
1806
1/2
✓ Branch 0 taken 396 times.
✗ Branch 1 not taken.
396 if(wait)
1807 {
1808 FFCore.warpScriptCheck();
1809 for(int32_t i=0; i<66; i++)
1810 {
1811 draw_screen(tmpscr);
1812 //put_passive_subscr(framebuf,0,passive_subscreen_offset,false,sspUP);
1813 advanceframe(true);
1814
1815 if(Quit)
1816 {
1817 break;
1818 }
1819 }
1820 }
1821 396 }
1822
1823 1111 void open_black_opening(int32_t x, int32_t y, bool wait, int32_t shape)
1824 {
1825
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1111 times.
1111 black_opening_shape= (shape>-1 ? shape : choose_opening_shape());
1826
1827 1111 int32_t w=256, h=224;
1828 1111 int32_t blockrows=28, blockcolumns=32;
1829 1111 int32_t xoffset=(x-(w/2))/8, yoffset=(y-(h/2))/8;
1830
1831
2/2
✓ Branch 0 taken 31108 times.
✓ Branch 1 taken 1111 times.
32219 for(int32_t blockrow=0; blockrow<blockrows; ++blockrow) //30
1832 {
1833
2/2
✓ Branch 0 taken 995456 times.
✓ Branch 1 taken 31108 times.
1026564 for(int32_t blockcolumn=0; blockcolumn<blockcolumns; ++blockcolumn) //40
1834 {
1835
2/2
✓ Branch 0 taken 442711 times.
✓ Branch 1 taken 552745 times.
995456 screen_triangles[blockrow][blockcolumn]=zc_max(abs(int32_t(double(blockcolumns-1)/2-blockcolumn+xoffset)),abs(int32_t(double(blockrows-1)/2-blockrow+yoffset)))|0x0100|((blockrow-yoffset<blockrows/2)?0:0x8000)|((blockcolumn-xoffset<blockcolumns/2)?0x4000:0);
1836 995456 }
1837 31108 }
1838
1839 1111 black_opening_count = -66;
1840 1111 black_opening_x = x;
1841 1111 black_opening_y = y;
1842 1111 lensclk = 0;
1843
1/2
✓ Branch 0 taken 1111 times.
✗ Branch 1 not taken.
1111 if(black_opening_shape == bosFADEBLACK)
1844 {
1845 refreshTints();
1846 memcpy(tempblackpal, RAMpal, sizeof(RAMpal)); //Store palette in temp palette for fade effect
1847 }
1848
2/2
✓ Branch 0 taken 199 times.
✓ Branch 1 taken 912 times.
1111 if(wait)
1849 {
1850 912 FFCore.warpScriptCheck();
1851
2/2
✓ Branch 0 taken 912 times.
✓ Branch 1 taken 60192 times.
61104 for(int32_t i=0; i<66; i++)
1852 {
1853 60192 draw_screen(tmpscr);
1854 //put_passive_subscr(framebuf,0,passive_subscreen_offset,false,sspUP);
1855 60192 advanceframe(true);
1856
1857
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 60192 times.
60192 if(Quit)
1858 {
1859 break;
1860 }
1861 60192 }
1862 912 }
1863 1111 }
1864
1865 99462 void black_opening(BITMAP *dest,int32_t x,int32_t y,int32_t a,int32_t max_a)
1866 {
1867 99462 clear_to_color(tmp_scr,BLACK);
1868 99462 int32_t w=256, h=224;
1869
1870
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 858 times.
✓ Branch 2 taken 660 times.
✓ Branch 3 taken 7656 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 90288 times.
99462 switch(black_opening_shape)
1871 {
1872 case bosOVAL:
1873 {
1874 858 double new_w=(w/2)+abs(w/2-x);
1875 858 double new_h=(h/2)+abs(h/2-y);
1876 858 double b=sqrt(((new_w*new_w)/4)+(new_h*new_h));
1877 858 ellipsefill(tmp_scr,x,y,int32_t(2*a*b/max_a)/8*8,int32_t(a*b/max_a)/8*8,0);
1878 858 break;
1879 }
1880
1881 case bosTRIANGLE:
1882 {
1883 660 double new_w=(w/2)+abs(w/2-x);
1884 660 double new_h=(h/2)+abs(h/2-y);
1885 660 double r=a*(new_w*sqrt((double)3)+new_h)/max_a;
1886 660 double P2= (PI/2);
1887 660 double P23=(2*PI/3);
1888 660 double P43=(4*PI/3);
1889 660 double Pa= (-4*PI*a/(3*max_a));
1890 660 double angle=P2+Pa;
1891 660 double a0=angle;
1892 660 double a2=angle+P23;
1893 660 double a4=angle+P43;
1894 1320 triangle(tmp_scr, x+int32_t(zc::math::Cos(a0)*r), y-int32_t(zc::math::Sin(a0)*r),
1895 660 x+int32_t(zc::math::Cos(a2)*r), y-int32_t(zc::math::Sin(a2)*r),
1896 660 x+int32_t(zc::math::Cos(a4)*r), y-int32_t(zc::math::Sin(a4)*r),
1897 0);
1898 660 break;
1899 }
1900
1901 case bosSMAS:
1902 {
1903
2/2
✓ Branch 0 taken 2838 times.
✓ Branch 1 taken 4818 times.
7656 int32_t distance=zc_max(abs(w/2-x),abs(h/2-y))/8;
1904
1905
2/2
✓ Branch 0 taken 214368 times.
✓ Branch 1 taken 7656 times.
222024 for(int32_t blockrow=0; blockrow<28; ++blockrow) //30
1906 {
1907
2/2
✓ Branch 0 taken 1714944 times.
✓ Branch 1 taken 214368 times.
1929312 for(int32_t linerow=0; linerow<8; ++linerow)
1908 {
1909 1714944 qword *triangleline=(qword*)(tmp_scr->line[(blockrow*8+linerow)]);
1910
1911
2/2
✓ Branch 0 taken 54878208 times.
✓ Branch 1 taken 1714944 times.
56593152 for(int32_t blockcolumn=0; blockcolumn<32; ++blockcolumn) //40
1912 {
1913 164634624 *triangleline=triangles[(screen_triangles[blockrow][blockcolumn]&0xC000)>>14]
1914
6/6
✓ Branch 0 taken 38180568 times.
✓ Branch 1 taken 16697640 times.
✓ Branch 2 taken 35934032 times.
✓ Branch 3 taken 18944176 times.
✓ Branch 4 taken 19236392 times.
✓ Branch 5 taken 16697640 times.
54878208 [zc_min(zc_max((((31+distance)*(max_a-a)/max_a)+((screen_triangles[blockrow][blockcolumn]&0x0FFF)-0x0100)-(15+distance)),0),15)]
1915 54878208 [linerow];
1916 54878208 ++triangleline;
1917
1918
2/2
✓ Branch 0 taken 48018432 times.
✓ Branch 1 taken 6859776 times.
54878208 if(linerow==0)
1919 {
1920 6859776 }
1921 54878208 }
1922 1714944 }
1923 214368 }
1924
1925 7656 break;
1926 }
1927
1928 case bosFADEBLACK:
1929 {
1930 if(black_opening_count<0)
1931 {
1932 black_fade(zc_min(-black_opening_count,63));
1933 }
1934 else if(black_opening_count>0)
1935 {
1936 black_fade(63-zc_max(black_opening_count-3,0));
1937 }
1938 else black_fade(0);
1939 return; //no blitting from tmp_scr!
1940 }
1941
1942 90288 case bosCIRCLE:
1943 default:
1944 {
1945 90288 double new_w=(w/2)+abs(w/2-x);
1946 90288 double new_h=(h/2)+abs(h/2-y);
1947 90288 int32_t r=int32_t(sqrt((new_w*new_w)+(new_h*new_h))*a/max_a);
1948 //circlefill(tmp_scr,x,y,a<<3,0);
1949 90288 circlefill(tmp_scr,x,y,r,0);
1950 90288 break;
1951 }
1952 }
1953
1954 99462 masked_blit(tmp_scr,dest,0,0,0,0,320,240);
1955 99462 }
1956
1957
1958 void black_fade(int32_t fadeamnt)
1959 {
1960 for(int32_t i=0; i < 0xEF; i++)
1961 {
1962 RAMpal[i].r = vbound(tempblackpal[i].r-fadeamnt,0,63);
1963 RAMpal[i].g = vbound(tempblackpal[i].g-fadeamnt,0,63);
1964 RAMpal[i].b = vbound(tempblackpal[i].b-fadeamnt,0,63);
1965 }
1966
1967 refreshpal = true;
1968 }
1969
1970 //----------------------------------------------------------------
1971
1972 44453039 bool item_disabled(int32_t item) //is this item disabled?
1973 {
1974
2/2
✓ Branch 0 taken 1796436 times.
✓ Branch 1 taken 42656603 times.
44453039 return (unsigned(item) < MAXITEMS && game->items_off[item] != 0);
1975 }
1976
1977 7617843 bool can_use_item(int32_t item_type, int32_t item) //can Hero use this item?
1978 {
1979
2/2
✓ Branch 0 taken 135248 times.
✓ Branch 1 taken 7482595 times.
7617843 if(current_item(item_type, true) >=item)
1980 {
1981 135248 return true;
1982 }
1983
1984 7482595 return false;
1985 7617843 }
1986
1987 31051977 bool has_item(int32_t item_type, int32_t it) //does Hero possess this item?
1988 {
1989
5/9
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 6053367 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3220277 times.
✓ Branch 6 taken 16169148 times.
✓ Branch 7 taken 5493498 times.
✓ Branch 8 taken 115687 times.
31051977 switch(item_type)
1990 {
1991 case itype_bomb:
1992 case itype_sbomb:
1993 {
1994 int32_t itemid = getItemID(itemsbuf, item_type, it);
1995
1996 if(itemid == -1)
1997 return false;
1998
1999 return (game->get_item(itemid));
2000 }
2001
2002 case itype_clock:
2003 {
2004 6053367 int32_t itemid = getItemID(itemsbuf, item_type, it);
2005
2006
2/4
✓ Branch 0 taken 6053367 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6053367 times.
✗ Branch 3 not taken.
6053367 if(itemid != -1 && (itemsbuf[itemid].flags & ITEM_FLAG1)) //Active clock
2007 return (game->get_item(itemid));
2008 6053367 return Hero.getClock()?1:0;
2009 }
2010
2011 case itype_key:
2012 return (game->get_keys()>0);
2013
2014 case itype_magiccontainer:
2015 return (game->get_maxmagic()>=game->get_mp_per_block());
2016
2017 case itype_triforcepiece: //it: -2=any, -1=current level, other=that level
2018 {
2019
1/3
✓ Branch 0 taken 3220277 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
3220277 switch(it)
2020 {
2021 case -2:
2022 {
2023 for(int32_t i=0; i<MAXLEVELS; i++)
2024 {
2025 if(game->lvlitems[i]&liTRIFORCE)
2026 {
2027 return true;
2028 }
2029 }
2030
2031 return false;
2032 }
2033
2034 case -1:
2035 return (game->lvlitems[dlevel]&liTRIFORCE);
2036
2037 default:
2038
2/4
✓ Branch 0 taken 3220277 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3220277 times.
3220277 if(it>=0&&it<MAXLEVELS)
2039 {
2040 3220277 return (game->lvlitems[it]&liTRIFORCE);
2041 }
2042
2043 break;
2044 }
2045
2046 return 0;
2047 }
2048
2049 case itype_map: //it: -2=any, -1=current level, other=that level
2050 {
2051
1/3
✓ Branch 0 taken 16169148 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
16169148 switch(it)
2052 {
2053 case -2:
2054 {
2055 for(int32_t i=0; i<MAXLEVELS; i++)
2056 {
2057 if(game->lvlitems[i]&liMAP)
2058 {
2059 return true;
2060 }
2061 }
2062
2063 return false;
2064 }
2065
2066 case -1:
2067 return (game->lvlitems[dlevel]&liMAP)!=0;
2068
2069 default:
2070
2/4
✓ Branch 0 taken 16169148 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 16169148 times.
16169148 if(it>=0&&it<MAXLEVELS)
2071 {
2072 16169148 return (game->lvlitems[it]&liMAP)!=0;
2073 }
2074
2075 break;
2076 }
2077
2078 return 0;
2079 }
2080
2081 case itype_compass: //it: -2=any, -1=current level, other=that level
2082 {
2083
1/3
✓ Branch 0 taken 5493498 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
5493498 switch(it)
2084 {
2085 case -2:
2086 {
2087 for(int32_t i=0; i<MAXLEVELS; i++)
2088 {
2089 if(game->lvlitems[i]&liCOMPASS)
2090 {
2091 return true;
2092 }
2093 }
2094
2095 return false;
2096 }
2097
2098 case -1:
2099 return (game->lvlitems[dlevel]&liCOMPASS)!=0;
2100
2101 default:
2102
2/4
✓ Branch 0 taken 5493498 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5493498 times.
✗ Branch 3 not taken.
5493498 if(it>=0&&it<MAXLEVELS)
2103 {
2104 5493498 return (game->lvlitems[it]&liCOMPASS)!=0;
2105 }
2106
2107 break;
2108 }
2109 return 0;
2110 }
2111
2112 case itype_bosskey: //it: -2=any, -1=current level, other=that level
2113 {
2114
1/3
✓ Branch 0 taken 115687 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
115687 switch(it)
2115 {
2116 case -2:
2117 {
2118 for(int32_t i=0; i<MAXLEVELS; i++)
2119 {
2120 if(game->lvlitems[i]&liBOSSKEY)
2121 {
2122 return true;
2123 }
2124 }
2125
2126 return false;
2127 }
2128
2129 case -1:
2130 return (game->lvlitems[dlevel]&liBOSSKEY)?1:0;
2131
2132 default:
2133
2/4
✓ Branch 0 taken 115687 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 115687 times.
115687 if(it>=0&&it<MAXLEVELS)
2134 {
2135 115687 return (game->lvlitems[it]&liBOSSKEY)?1:0;
2136 }
2137 break;
2138 }
2139 return 0;
2140 }
2141
2142 default:
2143 //it=(1<<(it-1));
2144 /*if (item_type>=itype_max)
2145 {
2146 enter_sys_pal();
2147 jwin_alert("Error","has_item exception",NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
2148 exit_sys_pal();
2149
2150 return false;
2151 }*/
2152 int32_t itemid = getItemID(itemsbuf, item_type, it);
2153
2154 if(itemid == -1)
2155 return false;
2156
2157 return game->get_item(itemid);
2158 }
2159 31051977 }
2160
2161
2162 100011978 int32_t current_item(int32_t item_type, bool checkenabled) //item currently being used
2163 {
2164
9/9
✓ Branch 0 taken 6053367 times.
✓ Branch 1 taken 51585042 times.
✓ Branch 2 taken 6053367 times.
✓ Branch 3 taken 6053367 times.
✓ Branch 4 taken 6053367 times.
✓ Branch 5 taken 6053367 times.
✓ Branch 6 taken 6053367 times.
✓ Branch 7 taken 6053367 times.
✓ Branch 8 taken 6053367 times.
100011978 switch(item_type)
2165 {
2166 case itype_clock:
2167 {
2168 6053367 int32_t maxid = getHighestLevelOfFamily(game, itemsbuf, item_type, checkenabled);
2169
2170
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6053367 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6053367 if(maxid != -1 && (itemsbuf[maxid].flags & ITEM_FLAG1)) //Active clock
2171 return itemsbuf[maxid].fam_type;
2172
2173 6053367 return has_item(itype_clock,1) ? 1 : 0;
2174 }
2175
2176 case itype_key:
2177 6053367 return game->get_keys();
2178
2179 case itype_lkey:
2180 6053367 return game->lvlkeys[get_dlevel()];
2181
2182 case itype_magiccontainer:
2183 6053367 return game->get_maxmagic()/game->get_mp_per_block();
2184
2185 case itype_triforcepiece:
2186 {
2187 6053367 int32_t count=0;
2188
2189
2/2
✓ Branch 0 taken 3099323904 times.
✓ Branch 1 taken 6053367 times.
3105377271 for(int32_t i=0; i<MAXLEVELS; i++)
2190 {
2191 3099323904 count+=(game->lvlitems[i]&liTRIFORCE)?1:0;
2192 3099323904 }
2193
2194 6053367 return count;
2195 }
2196
2197 case itype_map:
2198 {
2199 6053367 int32_t count=0;
2200
2201
2/2
✓ Branch 0 taken 3099323904 times.
✓ Branch 1 taken 6053367 times.
3105377271 for(int32_t i=0; i<MAXLEVELS; i++)
2202 {
2203 3099323904 count+=(game->lvlitems[i]&liMAP)?1:0;
2204 3099323904 }
2205
2206 6053367 return count;
2207 }
2208
2209 case itype_compass:
2210 {
2211 6053367 int32_t count=0;
2212
2213
2/2
✓ Branch 0 taken 3099323904 times.
✓ Branch 1 taken 6053367 times.
3105377271 for(int32_t i=0; i<MAXLEVELS; i++)
2214 {
2215 3099323904 count+=(game->lvlitems[i]&liCOMPASS)?1:0;
2216 3099323904 }
2217
2218 6053367 return count;
2219 }
2220
2221 case itype_bosskey:
2222 {
2223 6053367 int32_t count=0;
2224
2225
2/2
✓ Branch 0 taken 3099323904 times.
✓ Branch 1 taken 6053367 times.
3105377271 for(int32_t i=0; i<MAXLEVELS; i++)
2226 {
2227 3099323904 count+=(game->lvlitems[i]&liBOSSKEY)?1:0;
2228 3099323904 }
2229
2230 6053367 return count;
2231 }
2232
2233 default:
2234 51585042 int32_t maxid = getHighestLevelOfFamily(game, itemsbuf, item_type, checkenabled);
2235
2236
2/2
✓ Branch 0 taken 9873870 times.
✓ Branch 1 taken 41711172 times.
51585042 if(maxid == -1)
2237 41711172 return 0;
2238
2239 9873870 return itemsbuf[maxid].fam_type;
2240 }
2241 100011978 }
2242
2243 92394135 int32_t current_item(int32_t item_type) //item currently being used
2244 {
2245 92394135 return current_item(item_type, true);
2246 }
2247
2248 116 std::map<int32_t, int32_t> itemcache;
2249 116 std::map<int32_t, int32_t> itemcache_cost;
2250
2251 void removeFromItemCache(int32_t itemclass)
2252 {
2253 itemcache.erase(itemclass);
2254 itemcache_cost.erase(itemclass);
2255 }
2256
2257 5857125 void flushItemCache(bool justcost)
2258 {
2259 5857125 itemcache_cost.clear();
2260
2/2
✓ Branch 0 taken 5827094 times.
✓ Branch 1 taken 30031 times.
5857125 if(!justcost)
2261 30031 itemcache.clear();
2262
2/2
✓ Branch 0 taken 5826995 times.
✓ Branch 1 taken 99 times.
5827094 else if(replay_version_check(0,19))
2263 5826995 return;
2264
2265 //also fix the active subscreen if items were deleted -DD
2266
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30130 times.
30130 if(game != NULL)
2267 {
2268 30130 verifyBothWeapons();
2269 30130 refresh_subscr_items();
2270 30130 }
2271 5857125 }
2272
2273 // This is used often, so it should be as direct as possible.
2274 3376276306 int32_t _c_item_id_internal(int32_t itemtype, bool checkmagic, bool jinx_check, bool check_bunny)
2275 {
2276 3376276306 bool use_cost_cache = replay_version_check(19);
2277
2/2
✓ Branch 0 taken 3300716816 times.
✓ Branch 1 taken 75559490 times.
3376276306 if(jinx_check)
2278 {
2279
4/4
✓ Branch 0 taken 47353141 times.
✓ Branch 1 taken 28206349 times.
✓ Branch 2 taken 8273869 times.
✓ Branch 3 taken 39079272 times.
75559490 if(!(HeroSwordClk() || HeroItemClk()))
2280 39079272 jinx_check = false; //not jinxed
2281 75559490 }
2282
2/2
✓ Branch 0 taken 1047446 times.
✓ Branch 1 taken 3375228860 times.
3376276306 if(!Hero.BunnyClock())
2283 3375228860 check_bunny = false; //not bunnied
2284
2/2
✓ Branch 0 taken 3346669576 times.
✓ Branch 1 taken 29606730 times.
3376276306 if(itemtype == itype_ring) checkmagic = true;
2285
4/4
✓ Branch 0 taken 3339796088 times.
✓ Branch 1 taken 36480218 times.
✓ Branch 2 taken 3308450265 times.
✓ Branch 3 taken 29257707 times.
6713984278 if (!jinx_check && !check_bunny
2286
3/4
✓ Branch 0 taken 3339796088 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3337707972 times.
✓ Branch 3 taken 2088116 times.
3339796088 && (use_cost_cache || itemtype != itype_ring))
2287 {
2288
4/4
✓ Branch 0 taken 185317066 times.
✓ Branch 1 taken 3125221315 times.
✓ Branch 2 taken 185130755 times.
✓ Branch 3 taken 186311 times.
3310538381 auto& cache = checkmagic && use_cost_cache ? itemcache_cost : itemcache;
2289 3310538381 auto res = cache.find(itemtype);
2290
2291
2/2
✓ Branch 0 taken 3295212171 times.
✓ Branch 1 taken 15326210 times.
3310538381 if(res != cache.end())
2292 3295212171 return res->second;
2293 15326210 }
2294
2295 81064135 int32_t result = -1;
2296 81064135 int32_t highestlevel = -1;
2297
2298
2/2
✓ Branch 0 taken 20752418560 times.
✓ Branch 1 taken 81064135 times.
20833482695 for(int32_t i=0; i<MAXITEMS; i++)
2299 {
2300
5/6
✓ Branch 0 taken 1522409302 times.
✓ Branch 1 taken 19230009258 times.
✓ Branch 2 taken 21890842 times.
✓ Branch 3 taken 1500518460 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 21890842 times.
20752418560 if(game->get_item(i) && itemsbuf[i].family==itemtype && !item_disabled(i))
2301 {
2302
4/4
✓ Branch 0 taken 20046815 times.
✓ Branch 1 taken 1844027 times.
✓ Branch 2 taken 8694 times.
✓ Branch 3 taken 20038121 times.
21890842 if(checkmagic && itemtype != itype_magicring)
2303
2/2
✓ Branch 0 taken 20037951 times.
✓ Branch 1 taken 170 times.
20038121 if(!checkmagiccost(i))
2304 170 continue;
2305
6/6
✓ Branch 0 taken 18598411 times.
✓ Branch 1 taken 3292261 times.
✓ Branch 2 taken 243036 times.
✓ Branch 3 taken 3049225 times.
✓ Branch 4 taken 1846135 times.
✓ Branch 5 taken 1446126 times.
21890672 if(jinx_check && (usesSwordJinx(i) ? HeroSwordClk() : HeroItemClk()))
2306
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1446126 times.
1446126 if(!(itemsbuf[i].flags & ITEM_JINX_IMMUNE))
2307 1446126 continue;
2308
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 20444546 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
20444546 if(check_bunny && !checkbunny(i))
2309 continue;
2310
2311
2/2
✓ Branch 0 taken 280132 times.
✓ Branch 1 taken 20164414 times.
20444546 if(itemsbuf[i].fam_type >= highestlevel)
2312 {
2313 20164414 highestlevel = itemsbuf[i].fam_type;
2314 20164414 result=i;
2315 20164414 }
2316 20444546 }
2317 20750972264 }
2318
2319
3/4
✓ Branch 0 taken 44583917 times.
✓ Branch 1 taken 36480218 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 44583917 times.
81064135 if(!(jinx_check || check_bunny)) //Can't cache jinx_check/check_bunny
2320 {
2321
2/2
✓ Branch 0 taken 2514 times.
✓ Branch 1 taken 44581403 times.
44583917 if (use_cost_cache)
2322 {
2323
2/2
✓ Branch 0 taken 894 times.
✓ Branch 1 taken 1620 times.
2514 if (!checkmagic)
2324 1620 itemcache[itemtype] = result;
2325
5/6
✓ Branch 0 taken 1620 times.
✓ Branch 1 taken 894 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 1617 times.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
2514 if (checkmagic || result < 0 || checkmagiccost(result))
2326 2514 itemcache_cost[itemtype] = result;
2327 2514 }
2328 else
2329 {
2330 44581403 itemcache[itemtype] = result;
2331 }
2332 44583917 }
2333 81064135 return result;
2334 3376276306 }
2335
2336 // 'jinx_check' indicates that the highest level item *immune to jinxes* should be returned.
2337 3340240301 int32_t current_item_id(int32_t itype, bool checkmagic, bool jinx_check, bool check_bunny)
2338 {
2339
2/4
✓ Branch 0 taken 3340240301 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3340240301 times.
3340240301 if(itype < 0 || itype >= itype_max) return -1;
2340
1/2
✓ Branch 0 taken 3340240301 times.
✗ Branch 1 not taken.
3340240301 if(game->OverrideItems[itype] > -2)
2341 {
2342 auto ovid = game->OverrideItems[itype];
2343 if(ovid < 0 || ovid >= MAXITEMS)
2344 return -1;
2345 if(itemsbuf[ovid].family == itype)
2346 {
2347 if(itype == itype_magicring)
2348 checkmagic = false;
2349 else if(itype == itype_ring)
2350 checkmagic = true;
2351
2352 if(checkmagic && !checkmagiccost(ovid))
2353 return -1;
2354 if(jinx_check && !(itemsbuf[ovid].flags & ITEM_JINX_IMMUNE)
2355 && (usesSwordJinx(ovid) ? HeroSwordClk() : HeroItemClk()))
2356 return -1;
2357 return ovid;
2358 }
2359 }
2360 3340240301 auto ret = _c_item_id_internal(itype,checkmagic,jinx_check,check_bunny);
2361
2/2
✓ Branch 0 taken 39523485 times.
✓ Branch 1 taken 3300716816 times.
3340240301 if(!jinx_check) //If not already a jinx-immune-only check...
2362 {
2363 //And the player IS jinxed...
2364
4/4
✓ Branch 0 taken 3272853444 times.
✓ Branch 1 taken 27863372 times.
✓ Branch 2 taken 8172633 times.
✓ Branch 3 taken 3264680811 times.
3300716816 if(HeroSwordClk() || HeroItemClk())
2365 {
2366 //Then do a jinx-immune-only check here
2367 36036005 auto ret2 = _c_item_id_internal(itype,checkmagic,true,check_bunny);
2368 //And *IF IT FINDS A VALID ITEM*, return that one instead! -Em
2369 //Should NOT need a compat rule, as this should always return -1 in old quests.
2370
2/2
✓ Branch 0 taken 1261310 times.
✓ Branch 1 taken 34774695 times.
36036005 if(ret2 > -1) return ret2;
2371 34774695 }
2372 3299455506 }
2373 3338978991 return ret;
2374 3340240301 }
2375
2376 19333396 int32_t current_item_power(int32_t itemtype)
2377 {
2378 19333396 int32_t result = current_item_id(itemtype,true);
2379
2/2
✓ Branch 0 taken 14040642 times.
✓ Branch 1 taken 5292754 times.
19333396 return (result<0) ? 0 : itemsbuf[result].power;
2380 }
2381
2382 11 int32_t heart_container_id()
2383 {
2384
1/2
✓ Branch 0 taken 319 times.
✗ Branch 1 not taken.
319 for(int32_t i=0; i<MAXITEMS; i++)
2385 {
2386
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 308 times.
319 if(itemsbuf[i].family == itype_heartcontainer)
2387 {
2388 11 return i;
2389 }
2390 308 }
2391 return -1;
2392 11 }
2393
2394 6053367 int32_t item_tile_mod()
2395 {
2396 6053367 int32_t tile=0;
2397
2398
2/2
✓ Branch 0 taken 1206356 times.
✓ Branch 1 taken 4847011 times.
6053367 if(game->get_bombs())
2399 {
2400 4847011 int32_t itemid = current_item_id(itype_bomb,false);
2401
3/4
✓ Branch 0 taken 4681842 times.
✓ Branch 1 taken 165169 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4681842 times.
4847011 if(itemid > -1 && checkbunny(itemid))
2402 4681842 tile+=itemsbuf[itemid].ltm;
2403 4847011 }
2404
2405
2/2
✓ Branch 0 taken 4539291 times.
✓ Branch 1 taken 1514076 times.
6053367 if(game->get_sbombs())
2406 {
2407 1514076 int32_t itemid = current_item_id(itype_sbomb,false);
2408
3/4
✓ Branch 0 taken 1512648 times.
✓ Branch 1 taken 1428 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1512648 times.
1514076 if(itemid > -1 && checkbunny(itemid))
2409 1512648 tile+=itemsbuf[itemid].ltm;
2410 1514076 }
2411
2412
2/2
✓ Branch 0 taken 5943667 times.
✓ Branch 1 taken 109700 times.
6053367 if(current_item(itype_clock))
2413 {
2414 109700 int32_t itemid =
2415
1/2
✓ Branch 0 taken 109700 times.
✗ Branch 1 not taken.
109700 get_qr(qr_HARDCODED_LITEM_LTMS)
2416 ? iClock
2417 : getHighestLevelEvenUnowned(itemsbuf, itype_clock);
2418
2/4
✓ Branch 0 taken 109700 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 109700 times.
109700 if(itemid > -1 && checkbunny(itemid))
2419 109700 tile+=itemsbuf[itemid].ltm;
2420 109700 }
2421
2422
2/2
✓ Branch 0 taken 4672626 times.
✓ Branch 1 taken 1380741 times.
6053367 if(current_item(itype_key))
2423 {
2424 1380741 int32_t itemid =
2425
1/2
✓ Branch 0 taken 1380741 times.
✗ Branch 1 not taken.
1380741 get_qr(qr_HARDCODED_LITEM_LTMS)
2426 ? iKey
2427 : getHighestLevelEvenUnowned(itemsbuf, itype_key);
2428
2/4
✓ Branch 0 taken 1380741 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1380741 times.
1380741 if(itemid > -1 && checkbunny(itemid))
2429 1380741 tile+=itemsbuf[itemid].ltm;
2430 1380741 }
2431
2432
2/2
✓ Branch 0 taken 5786264 times.
✓ Branch 1 taken 267103 times.
6053367 if(current_item(itype_lkey))
2433 {
2434 267103 int32_t itemid =
2435
2/2
✓ Branch 0 taken 266193 times.
✓ Branch 1 taken 910 times.
267103 get_qr(qr_HARDCODED_LITEM_LTMS)
2436 ? iLevelKey
2437 910 : getHighestLevelEvenUnowned(itemsbuf, itype_lkey);
2438
2/4
✓ Branch 0 taken 267103 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 267103 times.
267103 if(itemid > -1 && checkbunny(itemid))
2439 267103 tile+=itemsbuf[itemid].ltm;
2440 267103 }
2441
2442
2/2
✓ Branch 0 taken 1256550 times.
✓ Branch 1 taken 4796817 times.
6053367 if(current_item(itype_map))
2443 {
2444 4796817 int32_t itemid =
2445
2/2
✓ Branch 0 taken 4796031 times.
✓ Branch 1 taken 786 times.
4796817 get_qr(qr_HARDCODED_LITEM_LTMS)
2446 ? iMap
2447 786 : getHighestLevelEvenUnowned(itemsbuf, itype_map);
2448
2/4
✓ Branch 0 taken 4796817 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4796817 times.
4796817 if(itemid > -1 && checkbunny(itemid))
2449 4796817 tile+=itemsbuf[itemid].ltm;
2450 4796817 }
2451
2452
2/2
✓ Branch 0 taken 1234668 times.
✓ Branch 1 taken 4818699 times.
6053367 if(current_item(itype_compass))
2453 {
2454 4818699 int32_t itemid =
2455
2/2
✓ Branch 0 taken 4737640 times.
✓ Branch 1 taken 81059 times.
4818699 get_qr(qr_HARDCODED_LITEM_LTMS)
2456 ? iCompass
2457 81059 : getHighestLevelEvenUnowned(itemsbuf, itype_compass);
2458
2/4
✓ Branch 0 taken 4818699 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4818699 times.
4818699 if(itemid > -1 && checkbunny(itemid))
2459 4818699 tile+=itemsbuf[itemid].ltm;
2460 4818699 }
2461
2462
2/2
✓ Branch 0 taken 3422822 times.
✓ Branch 1 taken 2630545 times.
6053367 if(current_item(itype_bosskey))
2463 {
2464 2630545 int32_t itemid =
2465
1/2
✓ Branch 0 taken 2630545 times.
✗ Branch 1 not taken.
2630545 get_qr(qr_HARDCODED_LITEM_LTMS)
2466 ? iBossKey
2467 : getHighestLevelEvenUnowned(itemsbuf, itype_bosskey);
2468
2/4
✓ Branch 0 taken 2630545 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2630545 times.
2630545 if(itemid > -1 && checkbunny(itemid))
2469 2630545 tile+=itemsbuf[itemid].ltm;
2470 2630545 }
2471
2472
2/2
✓ Branch 0 taken 2919391 times.
✓ Branch 1 taken 3133976 times.
6053367 if(current_item(itype_magiccontainer))
2473 {
2474 3133976 int32_t itemid =
2475
2/2
✓ Branch 0 taken 3040989 times.
✓ Branch 1 taken 92987 times.
3133976 get_qr(qr_HARDCODED_LITEM_LTMS)
2476 ? iMagicC
2477 92987 : getHighestLevelEvenUnowned(itemsbuf, itype_magiccontainer);
2478
3/4
✓ Branch 0 taken 3133976 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1870 times.
✓ Branch 3 taken 3132106 times.
3133976 if(itemid > -1 && checkbunny(itemid))
2479 3132106 tile+=itemsbuf[itemid].ltm;
2480 3133976 }
2481
2482
2/2
✓ Branch 0 taken 1592733 times.
✓ Branch 1 taken 4460634 times.
6053367 if(current_item(itype_triforcepiece))
2483 {
2484 4460634 int32_t itemid =
2485
1/2
✓ Branch 0 taken 4460634 times.
✗ Branch 1 not taken.
4460634 get_qr(qr_HARDCODED_LITEM_LTMS)
2486 ? iTriforce
2487 : getHighestLevelEvenUnowned(itemsbuf, itype_triforcepiece);
2488
2/4
✓ Branch 0 taken 4460634 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4460634 times.
4460634 if(itemid > -1 && checkbunny(itemid))
2489 4460634 tile+=itemsbuf[itemid].ltm;
2490 4460634 }
2491
2492
2/2
✓ Branch 0 taken 6053367 times.
✓ Branch 1 taken 3099323904 times.
3105377271 for(int32_t i=0; i<itype_max; i++)
2493 {
2494
2/2
✓ Branch 0 taken 3042451456 times.
✓ Branch 1 taken 56872448 times.
3099323904 if(!get_qr(qr_HARDCODED_LITEM_LTMS))
2495 {
2496
2/2
✓ Branch 0 taken 1110790 times.
✓ Branch 1 taken 55761658 times.
56872448 switch(i)
2497 {
2498 case itype_bomb:
2499 case itype_sbomb:
2500 case itype_clock:
2501 case itype_key:
2502 case itype_lkey:
2503 case itype_map:
2504 case itype_compass:
2505 case itype_bosskey:
2506 case itype_magiccontainer:
2507 case itype_triforcepiece:
2508 1110790 continue; //already handled
2509 }
2510 55761658 }
2511 3098213114 int32_t itemid = current_item_id(i,false);
2512
2/2
✓ Branch 0 taken 3092159747 times.
✓ Branch 1 taken 6053367 times.
3098213114 if(i == itype_shield)
2513 6053367 itemid = getCurrentShield(false);
2514
2515
4/4
✓ Branch 0 taken 80855172 times.
✓ Branch 1 taken 3017357942 times.
✓ Branch 2 taken 100981 times.
✓ Branch 3 taken 80754191 times.
3098213114 if(itemid < 0 || !checkbunny(itemid))
2516 3017458923 continue;
2517
2518 80754191 itemdata const& itm = itemsbuf[itemid];
2519
2520
2/2
✓ Branch 0 taken 75338158 times.
✓ Branch 1 taken 5416033 times.
80754191 switch(itm.family)
2521 {
2522 case itype_shield:
2523
1/2
✓ Branch 0 taken 5416033 times.
✗ Branch 1 not taken.
5416033 if(itm.flags & ITEM_FLAG9) //active shield
2524 {
2525 if(!usingActiveShield(itemid))
2526 {
2527 tile+=itm.misc6; //'Inactive PTM'
2528 continue;
2529 }
2530 }
2531 5416033 break;
2532 }
2533
2534 80754191 tile+=itm.ltm;
2535 80754191 }
2536
2537 6053367 return tile;
2538 }
2539
2540 6053367 int32_t bunny_tile_mod()
2541 {
2542
2/2
✓ Branch 0 taken 1870 times.
✓ Branch 1 taken 6051497 times.
6053367 if(Hero.BunnyClock())
2543 {
2544 1870 return game->get_bunny_ltm();
2545 }
2546 6051497 return 0;
2547 6053367 }
2548
2549 // Hints are drawn on a separate layer to combo reveals.
2550 16332 void draw_lens_under(BITMAP *dest, bool layer)
2551 {
2552 //Lens flag 1: Replacement for qr_LENSHINTS; if set, lens will show hints. Does nothing if flag 2 is set.
2553 //Lens flag 2: Disable "hints", prevent rendering of Secret Combos
2554 //Lens flag 3: Don't show armos/chest/dive items
2555 //Lens flag 4: Show Raft Paths
2556 //Lens flag 5: Show Invisible Enemies
2557
4/4
✓ Branch 0 taken 456 times.
✓ Branch 1 taken 15876 times.
✓ Branch 2 taken 7938 times.
✓ Branch 3 taken 7938 times.
16332 bool hints = (itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2) ? false : (layer && (itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG1));
2558
2559 16332 int32_t strike_hint_table[11]=
2560 {
2561 mfARROW, mfBOMB, mfBRANG, mfWANDMAGIC,
2562 mfSWORD, mfREFMAGIC, mfHOOKSHOT,
2563 mfREFFIREBALL, mfHAMMER, mfSWORDBEAM, mfWAND
2564 };
2565
2566 // int32_t page = tmpscr->cpage;
2567 {
2568 16332 int32_t blink_rate=flash_reduction_enabled()?6:1;
2569 // int32_t temptimer=0;
2570 16332 int32_t tempitem, tempweapon=0;
2571 16332 strike_hint=strike_hint_table[strike_hint_counter];
2572
2573
2/2
✓ Branch 0 taken 15842 times.
✓ Branch 1 taken 490 times.
16332 if(strike_hint_timer>32)
2574 {
2575 490 strike_hint_timer=0;
2576 490 strike_hint_counter=((strike_hint_counter+1)%11);
2577 490 }
2578
2579 16332 ++strike_hint_timer;
2580
2581
2/2
✓ Branch 0 taken 2874432 times.
✓ Branch 1 taken 16332 times.
2890764 for(int32_t i=0; i<176; i++)
2582 {
2583 2874432 int32_t x = (i & 15) << 4;
2584 2874432 int32_t y = (i & 0xF0) + playing_field_offset;
2585 2874432 int32_t tempitemx=-16, tempitemy=-16;
2586 2874432 int32_t tempweaponx=-16, tempweapony=-16;
2587
2588
2/2
✓ Branch 0 taken 5748864 times.
✓ Branch 1 taken 2874432 times.
8623296 for(int32_t iter=0; iter<2; ++iter)
2589 {
2590 5748864 int32_t checkflag=0;
2591
2592
2/2
✓ Branch 0 taken 2874432 times.
✓ Branch 1 taken 2874432 times.
5748864 if(iter==0)
2593 {
2594 2874432 checkflag=combobuf[tmpscr->data[i]].flag;
2595 2874432 }
2596 else
2597 {
2598 2874432 checkflag=tmpscr->sflag[i];
2599 }
2600
2601
2/2
✓ Branch 0 taken 5747766 times.
✓ Branch 1 taken 1098 times.
5748864 if(checkflag==mfSTRIKE)
2602 {
2603
2/2
✓ Branch 0 taken 192 times.
✓ Branch 1 taken 906 times.
1098 if(!hints)
2604 {
2605
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 906 times.
906 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSTRIKE],tmpscr->secretcset[sSTRIKE]);
2606 906 }
2607 else
2608 {
2609 192 checkflag = strike_hint;
2610 }
2611 1098 }
2612
2613
20/36
✓ Branch 0 taken 5706470 times.
✓ Branch 1 taken 3148 times.
✓ Branch 2 taken 3618 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2064 times.
✓ Branch 5 taken 28640 times.
✓ Branch 6 taken 2418 times.
✓ Branch 7 taken 504 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 814 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✓ Branch 14 taken 33 times.
✓ Branch 15 taken 96 times.
✓ Branch 16 taken 24 times.
✓ Branch 17 taken 5 times.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✓ Branch 21 taken 16 times.
✓ Branch 22 taken 16 times.
✓ Branch 23 taken 7 times.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✓ Branch 27 taken 16 times.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✓ Branch 31 taken 17 times.
✓ Branch 32 taken 35 times.
✓ Branch 33 taken 17 times.
✗ Branch 34 not taken.
✓ Branch 35 taken 906 times.
5748864 switch(checkflag)
2614 {
2615 case 0:
2616 case mfZELDA:
2617 case mfPUSHED:
2618 case mfENEMY0:
2619 case mfENEMY1:
2620 case mfENEMY2:
2621 case mfENEMY3:
2622 case mfENEMY4:
2623 case mfENEMY5:
2624 case mfENEMY6:
2625 case mfENEMY7:
2626 case mfENEMY8:
2627 case mfENEMY9:
2628 case mfSINGLE:
2629 case mfSINGLE16:
2630 case mfNOENEMY:
2631 case mfTRAP_H:
2632 case mfTRAP_V:
2633 case mfTRAP_4:
2634 case mfTRAP_LR:
2635 case mfTRAP_UD:
2636 case mfNOGROUNDENEMY:
2637 case mfNOBLOCKS:
2638 case mfSCRIPT1:
2639 case mfSCRIPT2:
2640 case mfSCRIPT3:
2641 case mfSCRIPT4:
2642 case mfSCRIPT5:
2643 case mfSCRIPT6:
2644 case mfSCRIPT7:
2645 case mfSCRIPT8:
2646 case mfSCRIPT9:
2647 case mfSCRIPT10:
2648 case mfSCRIPT11:
2649 case mfSCRIPT12:
2650 case mfSCRIPT13:
2651 case mfSCRIPT14:
2652 case mfSCRIPT15:
2653 case mfSCRIPT16:
2654 case mfSCRIPT17:
2655 case mfSCRIPT18:
2656 case mfSCRIPT19:
2657 case mfSCRIPT20:
2658 case mfPITHOLE:
2659 case mfPITFALLFLOOR:
2660 case mfLAVA:
2661 case mfICE:
2662 case mfICEDAMAGE:
2663 case mfDAMAGE1:
2664 case mfDAMAGE2:
2665 case mfDAMAGE4:
2666 case mfDAMAGE8:
2667 case mfDAMAGE16:
2668 case mfDAMAGE32:
2669 case mfFREEZEALL:
2670 case mfFREZEALLANSFFCS:
2671 case mfFREEZEFFCSOLY:
2672 case mfSCRITPTW1TRIG:
2673 case mfSCRITPTW2TRIG:
2674 case mfSCRITPTW3TRIG:
2675 case mfSCRITPTW4TRIG:
2676 case mfSCRITPTW5TRIG:
2677 case mfSCRITPTW6TRIG:
2678 case mfSCRITPTW7TRIG:
2679 case mfSCRITPTW8TRIG:
2680 case mfSCRITPTW9TRIG:
2681 case mfSCRITPTW10TRIG:
2682 case mfTROWEL:
2683 case mfTROWELNEXT:
2684 case mfTROWELSPECIALITEM:
2685 case mfSLASHPOT:
2686 case mfLIFTPOT:
2687 case mfLIFTORSLASH:
2688 case mfLIFTROCK:
2689 case mfLIFTROCKHEAVY:
2690 case mfDROPITEM:
2691 case mfSPECIALITEM:
2692 case mfDROPKEY:
2693 case mfDROPLKEY:
2694 case mfDROPCOMPASS:
2695 case mfDROPMAP:
2696 case mfDROPBOSSKEY:
2697 case mfSPAWNNPC:
2698 case mfSWITCHHOOK:
2699 case mfSIDEVIEWLADDER:
2700 case mfSIDEVIEWPLATFORM:
2701 case mfNOENEMYSPAWN:
2702 case mfENEMYALL:
2703 case mfNOMIRROR:
2704 case mfUNSAFEGROUND:
2705 case mf168:
2706 case mf169:
2707 case mf170:
2708 case mf171:
2709 case mf172:
2710 case mf173:
2711 case mf174:
2712 case mf175:
2713 case mf176:
2714 case mf177:
2715 case mf178:
2716 case mf179:
2717 case mf180:
2718 case mf181:
2719 case mf182:
2720 case mf183:
2721 case mf184:
2722 case mf185:
2723 case mf186:
2724 case mf187:
2725 case mf188:
2726 case mf189:
2727 case mf190:
2728 case mf191:
2729 case mf192:
2730 case mf193:
2731 case mf194:
2732 case mf195:
2733 case mf196:
2734 case mf197:
2735 case mf198:
2736 case mf199:
2737 case mf200:
2738 case mf201:
2739 case mf202:
2740 case mf203:
2741 case mf204:
2742 case mf205:
2743 case mf206:
2744 case mf207:
2745 case mf208:
2746 case mf209:
2747 case mf210:
2748 case mf211:
2749 case mf212:
2750 case mf213:
2751 case mf214:
2752 case mf215:
2753 case mf216:
2754 case mf217:
2755 case mf218:
2756 case mf219:
2757 case mf220:
2758 case mf221:
2759 case mf222:
2760 case mf223:
2761 case mf224:
2762 case mf225:
2763 case mf226:
2764 case mf227:
2765 case mf228:
2766 case mf229:
2767 case mf230:
2768 case mf231:
2769 case mf232:
2770 case mf233:
2771 case mf234:
2772 case mf235:
2773 case mf236:
2774 case mf237:
2775 case mf238:
2776 case mf239:
2777 case mf240:
2778 case mf241:
2779 case mf242:
2780 case mf243:
2781 case mf244:
2782 case mf245:
2783 case mf246:
2784 case mf247:
2785 case mf248:
2786 case mf249:
2787 case mf250:
2788 case mf251:
2789 case mf252:
2790 case mf253:
2791 case mf254:
2792 case mfEXTENDED:
2793 5706470 break;
2794
2795 case mfPUSHUD:
2796 case mfPUSHLR:
2797 case mfPUSH4:
2798 case mfPUSHU:
2799 case mfPUSHD:
2800 case mfPUSHL:
2801 case mfPUSHR:
2802 case mfPUSHUDNS:
2803 case mfPUSHLRNS:
2804 case mfPUSH4NS:
2805 case mfPUSHUNS:
2806 case mfPUSHDNS:
2807 case mfPUSHLNS:
2808 case mfPUSHRNS:
2809 case mfPUSHUDINS:
2810 case mfPUSHLRINS:
2811 case mfPUSH4INS:
2812 case mfPUSHUINS:
2813 case mfPUSHDINS:
2814 case mfPUSHLINS:
2815 case mfPUSHRINS:
2816
3/4
✓ Branch 0 taken 1829 times.
✓ Branch 1 taken 1319 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1829 times.
3148 if(!hints && ((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&16))
2817
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1829 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1829 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1829 || ((get_debug() && zc_getkey(KEY_N)) && (frame&16))))
2818 {
2819 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->undercombo,tmpscr->undercset);
2820 }
2821
2822
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3148 times.
3148 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2823
3/6
✓ Branch 0 taken 2438 times.
✓ Branch 1 taken 710 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 710 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
3148 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2824 {
2825
2/2
✓ Branch 0 taken 1406 times.
✓ Branch 1 taken 1032 times.
2438 if(hints)
2826 {
2827
3/3
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 63 times.
✓ Branch 2 taken 897 times.
1032 switch(combobuf[tmpscr->data[i]].type)
2828 {
2829 case cPUSH_HEAVY:
2830 case cPUSH_HW:
2831 72 tempitem=getItemIDPower(itemsbuf,itype_bracelet,1);
2832 72 tempitemx=x, tempitemy=y;
2833
2834
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 72 times.
72 if(tempitem>-1)
2835 72 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2836
2837 72 break;
2838
2839 case cPUSH_HEAVY2:
2840 case cPUSH_HW2:
2841 63 tempitem=getItemIDPower(itemsbuf,itype_bracelet,2);
2842 63 tempitemx=x, tempitemy=y;
2843
2844
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 63 times.
63 if(tempitem>-1)
2845 63 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2846
2847 63 break;
2848 }
2849 1032 }
2850 2438 }
2851
2852 3148 break;
2853
2854 case mfWHISTLE:
2855
1/2
✓ Branch 0 taken 2418 times.
✗ Branch 1 not taken.
2418 if(hints)
2856 {
2857 tempitem=getItemID(itemsbuf,itype_whistle,1);
2858
2859 if(tempitem<0) break;
2860
2861 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2862 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2863 {
2864 tempitemx=x;
2865 tempitemy=y;
2866 }
2867
2868 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2869 }
2870
2871 2418 break;
2872
2873 //Why is this here?
2874 case mfFAIRY:
2875 case mfMAGICFAIRY:
2876 case mfALLFAIRY:
2877 if(hints)
2878 {
2879 tempitem=getItemID(itemsbuf, itype_fairy,1);//iFairyMoving;
2880
2881 if(tempitem < 0) break;
2882
2883 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2884 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2885 {
2886 tempitemx=x;
2887 tempitemy=y;
2888 }
2889
2890 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2891 }
2892
2893 break;
2894
2895 case mfANYFIRE:
2896
2/2
✓ Branch 0 taken 252 times.
✓ Branch 1 taken 252 times.
504 if(!hints)
2897 {
2898
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 252 times.
252 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sBCANDLE],tmpscr->secretcset[sBCANDLE]);
2899 252 }
2900 else
2901 {
2902 252 tempitem=getItemID(itemsbuf,itype_candle,1);
2903
2904
1/2
✓ Branch 0 taken 252 times.
✗ Branch 1 not taken.
252 if(tempitem<0) break;
2905
2906
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 252 times.
252 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2907
3/6
✓ Branch 0 taken 189 times.
✓ Branch 1 taken 63 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 63 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
252 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2908 {
2909 189 tempitemx=x;
2910 189 tempitemy=y;
2911 189 }
2912
2913 252 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2914 }
2915
2916 504 break;
2917
2918 case mfSTRONGFIRE:
2919 if(!hints)
2920 {
2921 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sRCANDLE],tmpscr->secretcset[sRCANDLE]);
2922 }
2923 else
2924 {
2925 tempitem=getItemID(itemsbuf,itype_candle,2);
2926
2927 if(tempitem<0) break;
2928
2929 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2930 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2931 {
2932 tempitemx=x;
2933 tempitemy=y;
2934 }
2935
2936 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2937 }
2938
2939 break;
2940
2941 case mfMAGICFIRE:
2942 if(!hints)
2943 {
2944 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWANDFIRE],tmpscr->secretcset[sWANDFIRE]);
2945 }
2946 else
2947 {
2948 tempitem=getItemID(itemsbuf,itype_wand,1);
2949
2950 if(tempitem<0) break;
2951
2952 tempweapon=wFire;
2953
2954 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2955 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2956 {
2957 tempitemx=x;
2958 tempitemy=y;
2959 }
2960 else
2961 {
2962 tempweaponx=x;
2963 tempweapony=y;
2964 }
2965
2966 putweapon(dest,tempweaponx,tempweapony,tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
2967 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2968 }
2969
2970 break;
2971
2972 case mfDIVINEFIRE:
2973 if(!hints)
2974 {
2975 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sDIVINEFIRE],tmpscr->secretcset[sDIVINEFIRE]);
2976 }
2977 else
2978 {
2979 tempitem=getItemID(itemsbuf,itype_divinefire,1);
2980
2981 if(tempitem<0) break;
2982
2983 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2984 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2985 {
2986 tempitemx=x;
2987 tempitemy=y;
2988 }
2989
2990 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2991 }
2992
2993 break;
2994
2995 case mfARROW:
2996
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 732 times.
814 if(!hints)
2997 {
2998
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 732 times.
732 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sARROW],tmpscr->secretcset[sARROW]);
2999 732 }
3000 else
3001 {
3002 82 tempitem=getItemID(itemsbuf,itype_arrow,1);
3003
3004
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 if(tempitem<0) break;
3005
3006
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 82 times.
82 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3007
3/6
✓ Branch 0 taken 61 times.
✓ Branch 1 taken 21 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 21 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
82 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3008 {
3009 61 tempitemx=x;
3010 61 tempitemy=y;
3011 61 }
3012
3013 82 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3014 }
3015
3016 814 break;
3017
3018 case mfSARROW:
3019 if(!hints)
3020 {
3021 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSARROW],tmpscr->secretcset[sSARROW]);
3022 }
3023 else
3024 {
3025 tempitem=getItemID(itemsbuf,itype_arrow,2);
3026
3027 if(tempitem<0) break;
3028
3029 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3030 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3031 {
3032 tempitemx=x;
3033 tempitemy=y;
3034 }
3035
3036 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3037 }
3038
3039 break;
3040
3041 case mfGARROW:
3042 if(!hints)
3043 {
3044 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sGARROW],tmpscr->secretcset[sGARROW]);
3045 }
3046 else
3047 {
3048 tempitem=getItemID(itemsbuf,itype_arrow,3);
3049
3050 if(tempitem<0) break;
3051
3052 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3053 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3054 {
3055 tempitemx=x;
3056 tempitemy=y;
3057 }
3058
3059 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3060 }
3061
3062 break;
3063
3064 case mfBOMB:
3065
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 16 times.
33 if(!hints)
3066 {
3067
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sBOMB],tmpscr->secretcset[sBOMB]);
3068 16 }
3069 else
3070 {
3071 //tempitem=getItemID(itemsbuf,itype_bomb,1);
3072 17 tempweapon = wLitBomb;
3073
3074 //if (tempitem<0) break;
3075
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3076
3/6
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
17 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3077 {
3078 12 tempweaponx=x;
3079 12 tempweapony=y;
3080 12 }
3081
3082 17 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3083 }
3084
3085 33 break;
3086
3087 case mfSBOMB:
3088
2/2
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 48 times.
96 if(!hints)
3089 {
3090
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSBOMB],tmpscr->secretcset[sSBOMB]);
3091 48 }
3092 else
3093 {
3094 //tempitem=getItemID(itemsbuf,itype_sbomb,1);
3095 //if (tempitem<0) break;
3096 48 tempweapon = wLitSBomb;
3097
3098
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3099
3/6
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 12 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
48 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3100 {
3101 36 tempweaponx=x;
3102 36 tempweapony=y;
3103 36 }
3104
3105 48 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3106 }
3107
3108 96 break;
3109
3110 case mfARMOS_SECRET:
3111
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 12 times.
24 if(!hints)
3112 {
3113
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSTAIRS],tmpscr->secretcset[sSTAIRS]);
3114 12 }
3115 24 break;
3116
3117 case mfBRANG:
3118
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(!hints)
3119 {
3120 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sBRANG],tmpscr->secretcset[sBRANG]);
3121 }
3122 else
3123 {
3124 5 tempitem=getItemID(itemsbuf,itype_brang,1);
3125
3126
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(tempitem<0) break;
3127
3128
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3129
3/6
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
5 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3130 {
3131 4 tempitemx=x;
3132 4 tempitemy=y;
3133 4 }
3134
3135 5 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3136 }
3137
3138 5 break;
3139
3140 case mfMBRANG:
3141 if(!hints)
3142 {
3143 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sMBRANG],tmpscr->secretcset[sMBRANG]);
3144 }
3145 else
3146 {
3147 tempitem=getItemID(itemsbuf,itype_brang,2);
3148
3149 if(tempitem<0) break;
3150
3151 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3152 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3153 {
3154 tempitemx=x;
3155 tempitemy=y;
3156 }
3157
3158 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3159 }
3160
3161 break;
3162
3163 case mfFBRANG:
3164 if(!hints)
3165 {
3166 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sFBRANG],tmpscr->secretcset[sFBRANG]);
3167 }
3168 else
3169 {
3170 tempitem=getItemID(itemsbuf,itype_brang,3);
3171
3172 if(tempitem<0) break;
3173
3174 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3175 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3176 {
3177 tempitemx=x;
3178 tempitemy=y;
3179 }
3180
3181 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3182 }
3183
3184 break;
3185
3186 case mfWANDMAGIC:
3187 if(!hints)
3188 {
3189 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWANDMAGIC],tmpscr->secretcset[sWANDMAGIC]);
3190 }
3191 else
3192 {
3193 tempitem=getItemID(itemsbuf,itype_wand,1);
3194
3195 if(tempitem<0) break;
3196
3197 tempweapon=itemsbuf[tempitem].wpn3;
3198
3199 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3200 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3201 {
3202 tempitemx=x;
3203 tempitemy=y;
3204 }
3205 else
3206 {
3207 tempweaponx=x;
3208 tempweapony=y;
3209 --lens_hint_weapon[wMagic][4];
3210
3211 if(lens_hint_weapon[wMagic][4]<-8)
3212 {
3213 lens_hint_weapon[wMagic][4]=8;
3214 }
3215 }
3216
3217 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3218 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3219 }
3220
3221 break;
3222
3223 case mfREFMAGIC:
3224
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!hints)
3225 {
3226 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sREFMAGIC],tmpscr->secretcset[sREFMAGIC]);
3227 }
3228 else
3229 {
3230 16 tempitem=getItemID(itemsbuf,itype_shield,3);
3231
3232
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(tempitem<0) break;
3233
3234 16 tempweapon=ewMagic;
3235
3236
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3237
3/6
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
16 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3238 {
3239 13 tempitemx=x;
3240 13 tempitemy=y;
3241 13 }
3242 else
3243 {
3244 3 tempweaponx=x;
3245 3 tempweapony=y;
3246
3247
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 1 times.
3 if(lens_hint_weapon[ewMagic][2]==up)
3248 {
3249 1 --lens_hint_weapon[ewMagic][4];
3250 1 }
3251 else
3252 {
3253 2 ++lens_hint_weapon[ewMagic][4];
3254 }
3255
3256
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(lens_hint_weapon[ewMagic][4]>8)
3257 {
3258 lens_hint_weapon[ewMagic][2]=up;
3259 }
3260
3261
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 2 times.
3 if(lens_hint_weapon[ewMagic][4]<=0)
3262 {
3263 2 lens_hint_weapon[ewMagic][2]=down;
3264 2 }
3265 }
3266
3267 16 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3268 16 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, lens_hint_weapon[ewMagic][2], lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3269 }
3270
3271 16 break;
3272
3273 case mfREFFIREBALL:
3274
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!hints)
3275 {
3276 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sREFFIREBALL],tmpscr->secretcset[sREFFIREBALL]);
3277 }
3278 else
3279 {
3280 16 tempitem=getItemID(itemsbuf,itype_shield,3);
3281
3282
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(tempitem<0) break;
3283
3284 16 tempweapon=ewFireball;
3285
3286
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3287
3/6
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
16 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3288 {
3289 12 tempitemx=x;
3290 12 tempitemy=y;
3291 12 tempweaponx=x;
3292 12 tempweapony=y;
3293 12 ++lens_hint_weapon[ewFireball][3];
3294
3295
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 1 times.
12 if(lens_hint_weapon[ewFireball][3]>8)
3296 {
3297 1 lens_hint_weapon[ewFireball][3]=-8;
3298 1 lens_hint_weapon[ewFireball][4]=8;
3299 1 }
3300
3301
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 4 times.
12 if(lens_hint_weapon[ewFireball][3]>0)
3302 {
3303 8 ++lens_hint_weapon[ewFireball][4];
3304 8 }
3305 else
3306 {
3307 4 --lens_hint_weapon[ewFireball][4];
3308 }
3309 12 }
3310
3311 16 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3312 16 putweapon(dest,tempweaponx+lens_hint_weapon[tempweapon][3],tempweapony+lens_hint_weapon[ewFireball][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3313 }
3314
3315 16 break;
3316
3317 case mfSWORD:
3318
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 if(!hints)
3319 {
3320 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSWORD],tmpscr->secretcset[sSWORD]);
3321 }
3322 else
3323 {
3324 7 tempitem=getItemID(itemsbuf,itype_sword,1);
3325
3326
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 if(tempitem<0) break;
3327
3328
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3329
3/6
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
7 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3330 {
3331 5 tempitemx=x;
3332 5 tempitemy=y;
3333 5 }
3334
3335 7 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3336 }
3337
3338 7 break;
3339
3340 case mfWSWORD:
3341 if(!hints)
3342 {
3343 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWSWORD],tmpscr->secretcset[sWSWORD]);
3344 }
3345 else
3346 {
3347 tempitem=getItemID(itemsbuf,itype_sword,2);
3348
3349 if(tempitem<0) break;
3350
3351 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3352 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3353 {
3354 tempitemx=x;
3355 tempitemy=y;
3356 }
3357
3358 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3359 }
3360
3361 break;
3362
3363 case mfMSWORD:
3364 if(!hints)
3365 {
3366 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sMSWORD],tmpscr->secretcset[sMSWORD]);
3367 }
3368 else
3369 {
3370 tempitem=getItemID(itemsbuf,itype_sword,3);
3371
3372 if(tempitem<0) break;
3373
3374 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3375 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3376 {
3377 tempitemx=x;
3378 tempitemy=y;
3379 }
3380
3381 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3382 }
3383
3384 break;
3385
3386 case mfXSWORD:
3387 if(!hints)
3388 {
3389 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sXSWORD],tmpscr->secretcset[sXSWORD]);
3390 }
3391 else
3392 {
3393 tempitem=getItemID(itemsbuf,itype_sword,4);
3394
3395 if(tempitem<0) break;
3396
3397 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3398 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3399 {
3400 tempitemx=x;
3401 tempitemy=y;
3402 }
3403
3404 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3405 }
3406
3407 break;
3408
3409 case mfSWORDBEAM:
3410
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!hints)
3411 {
3412 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSWORDBEAM],tmpscr->secretcset[sSWORDBEAM]);
3413 }
3414 else
3415 {
3416 16 tempitem=getItemID(itemsbuf,itype_sword,1);
3417
3418
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(tempitem<0) break;
3419
3420
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3421
3/6
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
16 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3422 {
3423 11 tempitemx=x;
3424 11 tempitemy=y;
3425 11 }
3426
3427 16 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 1);
3428 }
3429
3430 16 break;
3431
3432 case mfWSWORDBEAM:
3433 if(!hints)
3434 {
3435 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWSWORDBEAM],tmpscr->secretcset[sWSWORDBEAM]);
3436 }
3437 else
3438 {
3439 tempitem=getItemID(itemsbuf,itype_sword,2);
3440
3441 if(tempitem<0) break;
3442
3443 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3444 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3445 {
3446 tempitemx=x;
3447 tempitemy=y;
3448 }
3449
3450 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 2);
3451 }
3452
3453 break;
3454
3455 case mfMSWORDBEAM:
3456 if(!hints)
3457 {
3458 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sMSWORDBEAM],tmpscr->secretcset[sMSWORDBEAM]);
3459 }
3460 else
3461 {
3462 tempitem=getItemID(itemsbuf,itype_sword,3);
3463
3464 if(tempitem<0) break;
3465
3466 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3467 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3468 {
3469 tempitemx=x;
3470 tempitemy=y;
3471 }
3472
3473 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 3);
3474 }
3475
3476 break;
3477
3478 case mfXSWORDBEAM:
3479 if(!hints)
3480 {
3481 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sXSWORDBEAM],tmpscr->secretcset[sXSWORDBEAM]);
3482 }
3483 else
3484 {
3485 tempitem=getItemID(itemsbuf,itype_sword,4);
3486
3487 if(tempitem<0) break;
3488
3489 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3490 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3491 {
3492 tempitemx=x;
3493 tempitemy=y;
3494 }
3495
3496 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 4);
3497 }
3498
3499 break;
3500
3501 case mfHOOKSHOT:
3502
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!hints)
3503 {
3504 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sHOOKSHOT],tmpscr->secretcset[sHOOKSHOT]);
3505 }
3506 else
3507 {
3508 17 tempitem=getItemID(itemsbuf,itype_hookshot,1);
3509
3510
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(tempitem<0) break;
3511
3512
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3513
3/6
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
17 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3514 {
3515 12 tempitemx=x;
3516 12 tempitemy=y;
3517 12 }
3518
3519 17 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3520 }
3521
3522 17 break;
3523
3524 case mfWAND:
3525
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(!hints)
3526 {
3527 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWAND],tmpscr->secretcset[sWAND]);
3528 }
3529 else
3530 {
3531 35 tempitem=getItemID(itemsbuf,itype_wand,1);
3532
3533
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(tempitem<0) break;
3534
3535
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35 times.
35 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3536
3/6
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
35 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3537 {
3538 28 tempitemx=x;
3539 28 tempitemy=y;
3540 28 }
3541
3542 35 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3543 }
3544
3545 35 break;
3546
3547 case mfHAMMER:
3548
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!hints)
3549 {
3550 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sHAMMER],tmpscr->secretcset[sHAMMER]);
3551 }
3552 else
3553 {
3554 17 tempitem=getItemID(itemsbuf,itype_hammer,1);
3555
3556
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(tempitem<0) break;
3557
3558
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3559
3/6
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
17 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3560 {
3561 13 tempitemx=x;
3562 13 tempitemy=y;
3563 13 }
3564
3565 17 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3566 }
3567
3568 17 break;
3569
3570 case mfARMOS_ITEM:
3571 case mfDIVE_ITEM:
3572
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2064 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2064 times.
2064 if((!getmapflag() || (tmpscr->flags9&fBELOWRETURN)) && !(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG3))
3573 {
3574 2064 putitem2(dest,x,y,tmpscr->catchall, lens_hint_item[tmpscr->catchall][0], lens_hint_item[tmpscr->catchall][1], 0);
3575 2064 }
3576 2064 break;
3577
3578 case 16:
3579 case 17:
3580 case 18:
3581 case 19:
3582 case 20:
3583 case 21:
3584 case 22:
3585 case 23:
3586 case 24:
3587 case 25:
3588 case 26:
3589 case 27:
3590 case 28:
3591 case 29:
3592 case 30:
3593 case 31:
3594
2/2
✓ Branch 0 taken 1008 times.
✓ Branch 1 taken 2610 times.
3618 if(!hints)
3595
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2610 times.
5220 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3596 2610 putcombo(dest,x,y,tmpscr->secretcombo[checkflag-16+4],tmpscr->secretcset[checkflag-16+4]);
3597
3598 3618 break;
3599 case mfSECRETSNEXT:
3600 if(!hints)
3601 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3602 putcombo(dest,x,y,tmpscr->data[i]+1,tmpscr->cset[i]);
3603
3604 break;
3605
3606 case mfSTRIKE:
3607
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 906 times.
906 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3608 {
3609 906 goto special;
3610 }
3611 else
3612 {
3613 break;
3614 }
3615
3616 28640 default: goto special;
3617
3618 special:
3619
8/8
✓ Branch 0 taken 14677 times.
✓ Branch 1 taken 14869 times.
✓ Branch 2 taken 473 times.
✓ Branch 3 taken 14204 times.
✓ Branch 4 taken 441 times.
✓ Branch 5 taken 32 times.
✓ Branch 6 taken 6108 times.
✓ Branch 7 taken 8128 times.
29546 if(layer && ((checkflag!=mfRAFT && checkflag!=mfRAFT_BRANCH&& checkflag!=mfRAFT_BOUNCE) ||(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG4)))
3620 {
3621
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 6549 times.
✓ Branch 2 taken 4913 times.
✓ Branch 3 taken 1636 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1636 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
6549 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate)) || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3622 {
3623 4913 rectfill(dest,x,y,x+15,y+15,WHITE);
3624 4913 }
3625 6549 }
3626
3627 29546 break;
3628 }
3629 5748864 }
3630 2874432 }
3631
3632
2/2
✓ Branch 0 taken 8166 times.
✓ Branch 1 taken 8166 times.
16332 if(layer)
3633 {
3634
2/2
✓ Branch 0 taken 7978 times.
✓ Branch 1 taken 188 times.
8166 if(tmpscr->door[0]==dWALK)
3635 188 rectfill(dest, 120, 16+playing_field_offset, 135, 31+playing_field_offset, WHITE);
3636
3637
2/2
✓ Branch 0 taken 7969 times.
✓ Branch 1 taken 197 times.
8166 if(tmpscr->door[1]==dWALK)
3638 197 rectfill(dest, 120, 144+playing_field_offset, 135, 159+playing_field_offset, WHITE);
3639
3640
2/2
✓ Branch 0 taken 8014 times.
✓ Branch 1 taken 152 times.
8166 if(tmpscr->door[2]==dWALK)
3641 152 rectfill(dest, 16, 80+playing_field_offset, 31, 95+playing_field_offset, WHITE);
3642
3643
2/2
✓ Branch 0 taken 7940 times.
✓ Branch 1 taken 226 times.
8166 if(tmpscr->door[3]==dWALK)
3644 226 rectfill(dest, 224, 80+playing_field_offset, 239, 95+playing_field_offset, WHITE);
3645
3646
2/2
✓ Branch 0 taken 8123 times.
✓ Branch 1 taken 43 times.
8166 if(tmpscr->door[0]==dBOMB)
3647 {
3648 43 showbombeddoor(dest, 0);
3649 43 }
3650
3651
2/2
✓ Branch 0 taken 8127 times.
✓ Branch 1 taken 39 times.
8166 if(tmpscr->door[1]==dBOMB)
3652 {
3653 39 showbombeddoor(dest, 1);
3654 39 }
3655
3656
1/2
✓ Branch 0 taken 8166 times.
✗ Branch 1 not taken.
8166 if(tmpscr->door[2]==dBOMB)
3657 {
3658 showbombeddoor(dest, 2);
3659 }
3660
3661
2/2
✓ Branch 0 taken 8129 times.
✓ Branch 1 taken 37 times.
8166 if(tmpscr->door[3]==dBOMB)
3662 {
3663 37 showbombeddoor(dest, 3);
3664 37 }
3665 8166 }
3666
3667
2/2
✓ Branch 0 taken 14298 times.
✓ Branch 1 taken 2034 times.
16332 if(tmpscr->stairx + tmpscr->stairy)
3668 {
3669
2/2
✓ Branch 0 taken 911 times.
✓ Branch 1 taken 1123 times.
2034 if(!hints)
3670 {
3671
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1123 times.
1123 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3672 1123 putcombo(dest,tmpscr->stairx,tmpscr->stairy+playing_field_offset,tmpscr->secretcombo[sSTAIRS],tmpscr->secretcset[sSTAIRS]);
3673 1123 }
3674 else
3675 {
3676
2/2
✓ Branch 0 taken 863 times.
✓ Branch 1 taken 48 times.
911 if(tmpscr->flags&fWHISTLE)
3677 {
3678 48 tempitem=getItemID(itemsbuf,itype_whistle,1);
3679 48 int32_t tempitemx=-16;
3680 48 int32_t tempitemy=-16;
3681
3682
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&(blink_rate/4)))
3683
3/6
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 24 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 24 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
48 || ((get_debug() && zc_getkey(KEY_N)) && (frame&(blink_rate/4))))
3684 {
3685 24 tempitemx=tmpscr->stairx;
3686 24 tempitemy=tmpscr->stairy+playing_field_offset;
3687 24 }
3688
3689 48 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3690 48 }
3691 }
3692 2034 }
3693 }
3694 16332 }
3695
3696 BITMAP *lens_scr_d; // The "d" is for "destructible"!
3697
3698 7997 void draw_lens_over()
3699 {
3700 // Oh, what the heck.
3701 static BITMAP *lens_scr = NULL;
3702 static int32_t last_width = -1;
3703 7997 int32_t width = itemsbuf[current_item_id(itype_lens,true)].misc1;
3704
3705 // Only redraw the circle if the size has changed
3706
2/2
✓ Branch 0 taken 7987 times.
✓ Branch 1 taken 10 times.
7997 if(width != last_width)
3707 {
3708
1/2
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
10 if(lens_scr == NULL)
3709 {
3710 10 lens_scr = create_bitmap_ex(8,2*288,2*(240-playing_field_offset));
3711 10 }
3712
3713 10 clear_to_color(lens_scr, BLACK);
3714 10 circlefill(lens_scr, 288, 240-playing_field_offset, width, 0);
3715 10 circle(lens_scr, 288, 240-playing_field_offset, width+2, 0);
3716 10 circle(lens_scr, 288, 240-playing_field_offset, width+5, 0);
3717 10 last_width=width;
3718 10 }
3719
3720 7997 masked_blit(lens_scr, framebuf, 288-(HeroX()+8), 240-playing_field_offset-(HeroY()+8), 0, playing_field_offset, 256, 168);
3721 7997 do_primitives(framebuf, SPLAYER_LENS_OVER, tmpscr, 0, playing_field_offset);
3722 7997 }
3723
3724 //----------------------------------------------------------------
3725
3726 31111 void draw_wavy(BITMAP *source, BITMAP *target, int32_t amplitude, bool interpol)
3727 {
3728 //recreating a big bitmap every frame is highly sluggish.
3729
4/6
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 31108 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
31111 static BITMAP *wavebuf = create_bitmap_ex(8,288,240-original_playing_field_offset);
3730 31111 clear_to_color(wavebuf, BLACK);
3731 31111 blit(source,wavebuf,0,original_playing_field_offset,16,0,256,224-original_playing_field_offset);
3732
3733 int32_t ofs;
3734 // int32_t amplitude=8;
3735 // int32_t wavelength=4;
3736
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31111 times.
31111 amplitude = zc_min(2048,amplitude); // some arbitrary limit to prevent crashing
3737
3/6
✓ Branch 0 taken 31111 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 31111 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 31111 times.
31111 if(flash_reduction_enabled() && !get_qr(qr_WAVY_NO_EPILEPSY)) amplitude = zc_min(16,amplitude);
3738 31111 int32_t amp2=168;
3739
2/4
✓ Branch 0 taken 31111 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 31111 times.
31111 if(flash_reduction_enabled() && !get_qr(qr_WAVY_NO_EPILEPSY_2)) amp2*=2;
3740 31111 int32_t i=frame%amp2;
3741
3742
2/2
✓ Branch 0 taken 5226648 times.
✓ Branch 1 taken 31111 times.
5257759 for(int32_t j=0; j<168; j++)
3743 {
3744
3/4
✓ Branch 0 taken 2613324 times.
✓ Branch 1 taken 2613324 times.
✓ Branch 2 taken 2613324 times.
✗ Branch 3 not taken.
5226648 if(j&1 && interpol)
3745 {
3746 // Add 288*2048 to ensure it's never negative. It'll get modded out.
3747 ofs=288*2048+int32_t(zc::math::Sin((double(i+j)*2*PI/amp2))*amplitude);
3748 }
3749 else
3750 {
3751 5226648 ofs=288*2048-int32_t(zc::math::Sin((double(i+j)*2*PI/amp2))*amplitude);
3752 }
3753
3754
1/2
✓ Branch 0 taken 5226648 times.
✗ Branch 1 not taken.
5226648 if(ofs)
3755 {
3756
2/2
✓ Branch 0 taken 1338021888 times.
✓ Branch 1 taken 5226648 times.
1343248536 for(int32_t k=0; k<256; k++)
3757 {
3758 1338021888 target->line[j+original_playing_field_offset][k]=wavebuf->line[j][(k+ofs+16)%288];
3759 1338021888 }
3760 5226648 }
3761 5226648 }
3762 31111 }
3763
3764 4848 void draw_fuzzy(int32_t fuzz)
3765 // draws from right half of scrollbuf to framebuf
3766 {
3767 int32_t firstx, firsty, xstep, ystep, i, y, dx, dy;
3768 byte *start, *si, *di;
3769
3770
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4848 times.
4848 if(fuzz<1)
3771 fuzz = 1;
3772
3773 4848 xstep = 128%fuzz;
3774
3775
2/2
✓ Branch 0 taken 1010 times.
✓ Branch 1 taken 3838 times.
4848 if(xstep > 0)
3776 3838 xstep = fuzz-xstep;
3777
3778 4848 ystep = 112%fuzz;
3779
3780
2/2
✓ Branch 0 taken 1414 times.
✓ Branch 1 taken 3434 times.
4848 if(ystep > 0)
3781 3434 ystep = fuzz-ystep;
3782
3783 4848 firsty = 1;
3784
3785
2/2
✓ Branch 0 taken 4848 times.
✓ Branch 1 taken 174932 times.
179780 for(y=0; y<224;)
3786 {
3787 174932 start = &(scrollbuf->line[y][256]);
3788
3789
4/4
✓ Branch 0 taken 172508 times.
✓ Branch 1 taken 1088376 times.
✓ Branch 2 taken 1085952 times.
✓ Branch 3 taken 174932 times.
1260884 for(dy=0; dy<ystep && dy+y<224; dy++)
3790 {
3791 1085952 si = start;
3792 1085952 di = &(framebuf->line[y+dy][0]);
3793 1085952 i = xstep;
3794 1085952 firstx = 1;
3795
3796
2/2
✓ Branch 0 taken 278003712 times.
✓ Branch 1 taken 1085952 times.
279089664 for(dx=0; dx<256; dx++)
3797 {
3798 278003712 *(di++) = *si;
3799
3800
2/2
✓ Branch 0 taken 234248896 times.
✓ Branch 1 taken 43754816 times.
278003712 if(++i >= fuzz)
3801 {
3802
2/2
✓ Branch 0 taken 42668864 times.
✓ Branch 1 taken 1085952 times.
43754816 if(!firstx)
3803 42668864 si += fuzz;
3804 else
3805 {
3806 1085952 si += fuzz-xstep;
3807 1085952 firstx = 0;
3808 }
3809
3810 43754816 i = 0;
3811 43754816 }
3812 278003712 }
3813 1085952 }
3814
3815
2/2
✓ Branch 0 taken 170084 times.
✓ Branch 1 taken 4848 times.
174932 if(!firsty)
3816 170084 y += fuzz;
3817 else
3818 {
3819 4848 y += ystep;
3820 4848 ystep = fuzz;
3821 4848 firsty = 0;
3822 }
3823 }
3824 4848 }
3825
3826 9286804 void updatescr(bool allowwavy)
3827 {
3828
4/6
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 9286688 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 116 times.
✓ Branch 4 taken 116 times.
✗ Branch 5 not taken.
9286804 static BITMAP *wavybuf = create_bitmap_ex(8,256,224);
3829
4/6
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 9286688 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 116 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 116 times.
9286804 static BITMAP *panorama = create_bitmap_ex(8,256,224);
3830
3831
2/2
✓ Branch 0 taken 9260039 times.
✓ Branch 1 taken 26765 times.
9286804 if(toogam)
3832 {
3833 26765 textout_ex(framebuf,font,"no walls",8,216,1,-1);
3834 26765 }
3835
3836
1/2
✓ Branch 0 taken 9286804 times.
✗ Branch 1 not taken.
9286804 if(Showpal)
3837 dump_pal(framebuf);
3838
3839
2/2
✓ Branch 0 taken 8985572 times.
✓ Branch 1 taken 301232 times.
9286804 if(!Playing)
3840 301232 black_opening_count=0;
3841
3842
2/2
✓ Branch 0 taken 9213478 times.
✓ Branch 1 taken 73326 times.
9286804 if(black_opening_count<0) //shape is opening up
3843 {
3844 73326 black_opening(framebuf,black_opening_x,black_opening_y,(66+black_opening_count),66);
3845
3846
2/4
✓ Branch 0 taken 73326 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 73326 times.
73326 if(Advance||(!Paused))
3847 {
3848 73326 ++black_opening_count;
3849 73326 }
3850 73326 }
3851
2/2
✓ Branch 0 taken 9187342 times.
✓ Branch 1 taken 26136 times.
9213478 else if(black_opening_count>0) //shape is closing
3852 {
3853 26136 black_opening(framebuf,black_opening_x,black_opening_y,black_opening_count,66);
3854
3855
2/4
✓ Branch 0 taken 26136 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 26136 times.
26136 if(Advance||(!Paused))
3856 {
3857 26136 --black_opening_count;
3858 26136 }
3859 26136 }
3860
3861
3/4
✓ Branch 0 taken 9188849 times.
✓ Branch 1 taken 97955 times.
✓ Branch 2 taken 9188849 times.
✗ Branch 3 not taken.
9286804 if(black_opening_count==0&&black_opening_shape==bosFADEBLACK)
3862 {
3863 black_opening_shape = bosCIRCLE;
3864 memcpy(RAMpal, tempblackpal, PAL_SIZE*sizeof(RGB));
3865 refreshTints();
3866 refreshpal=true;
3867 }
3868
3869
2/2
✓ Branch 0 taken 9032603 times.
✓ Branch 1 taken 254201 times.
9286804 if(refreshpal)
3870 {
3871 254201 refreshpal=false;
3872 254201 RAMpal[253] = _RGB(0,0,0);
3873 254201 RAMpal[254] = _RGB(63,63,63);
3874 254201 hw_palette = &RAMpal;
3875 254201 update_hw_pal = true;
3876
3877 254201 create_rgb_table(&rgb_table, RAMpal, NULL);
3878 254201 create_zc_trans_table(&trans_table, RAMpal, 128, 128, 128);
3879 254201 memcpy(&trans_table2, &trans_table, sizeof(COLOR_MAP));
3880
3881
2/2
✓ Branch 0 taken 65075456 times.
✓ Branch 1 taken 254201 times.
65329657 for(int32_t q=0; q<PAL_SIZE; q++)
3882 {
3883 65075456 trans_table2.data[0][q] = q;
3884 65075456 trans_table2.data[q][q] = q;
3885 65075456 }
3886 254201 }
3887
3888 9286804 bool clearwavy = (wavy <= 0);
3889
3890
2/2
✓ Branch 0 taken 7655 times.
✓ Branch 1 taken 9279149 times.
9286804 if(wavy <= 0)
3891 {
3892 // So far one thing can alter wavy apart from scripts: Wavy DMaps.
3893 9279149 wavy = (DMaps[currdmap].flags&dmfWAVY ? 4 : 0);
3894 9279149 }
3895
3896 9286804 blit(framebuf, wavybuf, 0, 0, 0, 0, 256, 224);
3897
3898
6/6
✓ Branch 0 taken 31361 times.
✓ Branch 1 taken 9255443 times.
✓ Branch 2 taken 31239 times.
✓ Branch 3 taken 122 times.
✓ Branch 4 taken 128 times.
✓ Branch 5 taken 31111 times.
9286804 if(wavy && Playing && allowwavy)
3899 {
3900 31111 draw_wavy(framebuf, wavybuf, wavy,false);
3901 31111 }
3902
3903
2/2
✓ Branch 0 taken 9279149 times.
✓ Branch 1 taken 7655 times.
9286804 if(clearwavy)
3904 9279149 wavy = 0; // Wavy was set by a DMap flag. Clear it.
3905
2/4
✓ Branch 0 taken 7655 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 7655 times.
7655 else if(Playing && !Paused)
3906 7655 wavy--; // Wavy was set by a script. Decrement it.
3907
3908
5/6
✓ Branch 0 taken 8985572 times.
✓ Branch 1 taken 301232 times.
✓ Branch 2 taken 259574 times.
✓ Branch 3 taken 8725998 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 259574 times.
9286804 if(Playing && msgpos && !screenscrolling)
3909 {
3910
1/2
✓ Branch 0 taken 259574 times.
✗ Branch 1 not taken.
259574 if(!(msg_bg_display_buf->clip))
3911 259574 blit_msgstr_bg(framebuf,0,0,0,playing_field_offset,256,168);
3912
1/2
✓ Branch 0 taken 259574 times.
✗ Branch 1 not taken.
259574 if(!(msg_portrait_display_buf->clip))
3913 259574 blit_msgstr_prt(framebuf,0,0,0,playing_field_offset,256,168);
3914
1/2
✓ Branch 0 taken 259574 times.
✗ Branch 1 not taken.
259574 if(!(msg_txt_display_buf->clip))
3915 259574 blit_msgstr_fg(framebuf,0,0,0,playing_field_offset,256,168);
3916 259574 }
3917
3918 /*
3919 if(!(msg_txt_display_buf->clip) && Playing && msgpos && !screenscrolling)
3920 {
3921 BITMAP* subBmp = 0;
3922 masked_blit(msg_txt_display_buf,subBmp,0,0,0,playing_field_offset,256,168);
3923 // masked_blit(msg_txt_display_buf,subBmp,0,playing_field_offset,256,168);
3924 draw_trans_sprite(framebuf, subBmp, 0, playing_field_offset);
3925 destroy_bitmap(subBmp);
3926 //void draw_sprite_ex(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t mode, int32_t flip);
3927 // masked_blit(msg_txt_display_buf,framebuf,0,0,0,playing_field_offset,256,168);
3928 //void masked_blit(BITMAP *source, BITMAP *dest, int32_t source_x, int32_t source_y, int32_t dest_x, int32_t dest_y, int32_t width, int32_t height);
3929 }
3930 */
3931
3932
2/2
✓ Branch 0 taken 9245747 times.
✓ Branch 1 taken 41057 times.
9286804 bool nosubscr = (tmpscr->flags3&fNOSUBSCR && !(tmpscr->flags3&fNOSUBSCROFFSET));
3933
3934
2/2
✓ Branch 0 taken 9250372 times.
✓ Branch 1 taken 36432 times.
9286804 if(nosubscr)
3935 {
3936 36432 rectfill(panorama,0,0,255,passive_subscreen_height/2,0);
3937 36432 rectfill(panorama,0,168+passive_subscreen_height/2,255,168+passive_subscreen_height-1,0);
3938 36432 blit(wavybuf,panorama,0,playing_field_offset,0,passive_subscreen_height/2,256,224-passive_subscreen_height);
3939 36432 }
3940
3941 //TODO: Optimize blit 'overcalls' -Gleeok
3942
2/2
✓ Branch 0 taken 36432 times.
✓ Branch 1 taken 9250372 times.
9286804 BITMAP *source = nosubscr ? panorama : wavybuf;
3943 9286804 blit(source,framebuf,0,0,0,0,256,224);
3944
3945 9286804 update_hw_screen();
3946 9286804 }
3947
3948 //----------------------------------------------------------------
3949
3950 static PALETTE syspal;
3951 int32_t onGUISnapshot()
3952 {
3953 char buf[200];
3954 int32_t num=0;
3955 bool realpal=(key[KEY_ZC_LCONTROL] || key[KEY_ZC_RCONTROL]);
3956 do
3957 {
3958 sprintf(buf, "%szc_screen%05d.%s", get_snap_str(), ++num, snapshotformat_str[SnapshotFormat][1]);
3959 }
3960 while(num<99999 && exists(buf));
3961
3962 BITMAP *b = create_bitmap_ex(8,resx,resy);
3963
3964 if(b)
3965 {
3966 blit(screen,b,0,0,0,0,resx,resy);
3967 save_bitmap(buf,screen,RAMpal);
3968 destroy_bitmap(b);
3969 }
3970
3971 return D_O_K;
3972 }
3973
3974 int32_t onNonGUISnapshot()
3975 {
3976 PALETTE temppal;
3977 get_palette(temppal);
3978 bool realpal=(zc_getkey(KEY_ZC_LCONTROL, true) || zc_getkey(KEY_ZC_RCONTROL, true));
3979
3980 char buf[200];
3981 int32_t num=0;
3982
3983 do
3984 {
3985 sprintf(buf, "%szc_screen%05d.%s", get_snap_str(), ++num, snapshotformat_str[SnapshotFormat][1]);
3986 }
3987 while(num<99999 && exists(buf));
3988
3989 if (tmpscr->flags3&fNOSUBSCR && !(key[KEY_ALT]))
3990 {
3991 BITMAP *b = create_bitmap_ex(8,256,168);
3992 clear_to_color(b,0);
3993 blit(framebuf,b,0,passive_subscreen_height/2,0,0,256,168);
3994 save_bitmap(buf,b,realpal?temppal:RAMpal);
3995 destroy_bitmap(b);
3996 }
3997 else
3998 {
3999 save_bitmap(buf,framebuf,realpal?temppal:RAMpal);
4000 }
4001
4002 return D_O_K;
4003 }
4004
4005 int32_t onSnapshot()
4006 {
4007 if(zc_getkey(KEY_LSHIFT, true)||zc_getkey(KEY_RSHIFT, true))
4008 {
4009 onGUISnapshot();
4010 }
4011 else
4012 {
4013 onNonGUISnapshot();
4014 }
4015
4016 return D_O_K;
4017 }
4018
4019 int32_t onSaveMapPic()
4020 {
4021 int32_t mapres2 = 0;
4022 char buf[200];
4023 int32_t num=0;
4024 mapscr tmpscr_b[2];
4025 mapscr tmpscr_c[6];
4026 BITMAP* _screen_draw_buffer = NULL;
4027 _screen_draw_buffer = create_bitmap_ex(8,256,224);
4028 set_clip_state(_screen_draw_buffer,1);
4029
4030 for(int32_t i=0; i<6; ++i)
4031 {
4032 tmpscr_c[i] = tmpscr2[i];
4033 tmpscr2[i].zero_memory();
4034
4035 if(i>=2)
4036 {
4037 continue;
4038 }
4039
4040 tmpscr_b[i] = tmpscr[i];
4041 tmpscr[i].zero_memory();
4042 }
4043
4044 do
4045 {
4046 sprintf(buf, "%szc_screen%05d.png", get_snap_str(), ++num);
4047 }
4048 while(num<99999 && exists(buf));
4049
4050 BITMAP* mappic = NULL;
4051
4052
4053 bool done=false, redraw=true;
4054
4055 mappic = create_bitmap_ex(8,(256*16)>>mapres,(176*8)>>mapres);
4056
4057 if(!mappic)
4058 {
4059 enter_sys_pal();
4060 jwin_alert("View Map","Not enough memory.",NULL,NULL,"OK",NULL,13,27,get_zc_font(font_lfont));
4061 exit_sys_pal();
4062 return D_O_K;;
4063 }
4064
4065 // draw the map
4066 set_clip_rect(_screen_draw_buffer, 0, 0, _screen_draw_buffer->w, _screen_draw_buffer->h);
4067
4068 for(int32_t y=0; y<8; y++)
4069 {
4070 for(int32_t x=0; x<16; x++)
4071 {
4072 if(!displayOnMap(x, y))
4073 {
4074 rectfill(_screen_draw_buffer, 0, 0, 255, 223, WHITE);
4075 }
4076 else
4077 {
4078 int32_t s = (y<<4) + x;
4079 loadscr2(1,s,-1);
4080
4081 for(int32_t i=0; i<6; i++)
4082 {
4083 if(tmpscr[1].layermap[i]<=0)
4084 continue;
4085
4086 if((ZCMaps[tmpscr[1].layermap[i]-1].tileWidth==ZCMaps[currmap].tileWidth) &&
4087 (ZCMaps[tmpscr[1].layermap[i]-1].tileHeight==ZCMaps[currmap].tileHeight))
4088 {
4089 const int32_t _mapsSize = (ZCMaps[currmap].tileWidth)*(ZCMaps[currmap].tileHeight);
4090
4091 tmpscr2[i]=TheMaps[(tmpscr[1].layermap[i]-1)*MAPSCRS+tmpscr[1].layerscreen[i]];
4092 }
4093 }
4094
4095 if(XOR((tmpscr+1)->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(_screen_draw_buffer, 0, 2, tmpscr+1, -256, playing_field_offset, 2);
4096
4097 if(XOR((tmpscr+1)->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(_screen_draw_buffer, 0, 3, tmpscr+1, -256, playing_field_offset, 2);
4098
4099 if(lenscheck(tmpscr+1,0)) putscr(_screen_draw_buffer,256,0,tmpscr+1);
4100 do_layer(_screen_draw_buffer, 0, 1, tmpscr+1, -256, playing_field_offset, 2);
4101
4102 if(!XOR((tmpscr+1)->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(_screen_draw_buffer, 0, 2, tmpscr+1, -256, playing_field_offset, 2);
4103
4104 putscrdoors(_screen_draw_buffer,256,0,tmpscr+1);
4105 if(get_qr(qr_PUSHBLOCK_SPRITE_LAYER))
4106 {
4107 do_layer(_screen_draw_buffer, -2, 0, tmpscr+1, -256, playing_field_offset, 2);
4108 if(get_qr(qr_PUSHBLOCK_LAYER_1_2))
4109 {
4110 do_layer(_screen_draw_buffer, -2, 1, tmpscr+1, -256, playing_field_offset, 2);
4111 do_layer(_screen_draw_buffer, -2, 2, tmpscr+1, -256, playing_field_offset, 2);
4112 }
4113 }
4114 do_layer(_screen_draw_buffer, -3, 0, tmpscr+1, -256, playing_field_offset, 2); // Freeform combos!
4115
4116 if(!XOR((tmpscr+1)->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(_screen_draw_buffer, 0, 3, tmpscr+1, -256, playing_field_offset, 2);
4117
4118 do_layer(_screen_draw_buffer, 0, 4, tmpscr+1, -256, playing_field_offset, 2);
4119 do_layer(_screen_draw_buffer, -1, 0, tmpscr+1, -256, playing_field_offset, 2);
4120 if(get_qr(qr_OVERHEAD_COMBOS_L1_L2))
4121 {
4122 do_layer(_screen_draw_buffer, -1, 1, tmpscr+1, -256, playing_field_offset, 2);
4123 do_layer(_screen_draw_buffer, -1, 2, tmpscr+1, -256, playing_field_offset, 2);
4124 }
4125 do_layer(_screen_draw_buffer, 0, 5, tmpscr+1, -256, playing_field_offset, 2);
4126 do_layer(_screen_draw_buffer, 0, 6, tmpscr+1, -256, playing_field_offset, 2);
4127
4128 }
4129
4130 stretch_blit(_screen_draw_buffer, mappic, 256, 0, 256, 176, x<<(8-mapres), (y*176)>>mapres, 256>>mapres, 176>>mapres);
4131 }
4132 }
4133
4134 for(int32_t i=0; i<6; ++i)
4135 {
4136 tmpscr2[i]=tmpscr_c[i];
4137
4138 if(i>=2)
4139 {
4140 continue;
4141 }
4142
4143 tmpscr[i]=tmpscr_b[i];
4144 }
4145
4146 save_bitmap(buf,mappic,RAMpal);
4147 destroy_bitmap(mappic);
4148 destroy_bitmap(_screen_draw_buffer);
4149 return D_O_K;
4150 }
4151
4152 14 void f_Quit(int32_t type)
4153 {
4154
2/4
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
14 if(type==qQUIT && !Playing)
4155 return;
4156
4157 14 bool from_menu = is_sys_pal;
4158
4159
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(!from_menu)
4160 {
4161 14 music_pause();
4162 14 pause_all_sfx();
4163 14 sys_mouse();
4164 14 }
4165 14 enter_sys_pal();
4166 14 clear_keybuf();
4167
4168
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 13 times.
14 if (replay_version_check(0, 10))
4169 13 replay_poll();
4170
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if (replay_is_replaying())
4171 14 replay_peek_quit();
4172
4173
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 if (!replay_is_replaying())
4174 switch(type)
4175 {
4176 case qQUIT:
4177 onQuit();
4178 break;
4179
4180 case qRESET:
4181 onReset();
4182 break;
4183
4184 case qEXIT:
4185 onExit();
4186 break;
4187 }
4188
4189
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 if(Quit)
4190 {
4191 14 kill_sfx();
4192 14 music_stop();
4193 14 exit_sys_pal();
4194 14 update_hw_screen();
4195 14 }
4196 else
4197 {
4198 exit_sys_pal();
4199 if(!from_menu)
4200 {
4201 music_resume();
4202 resume_all_sfx();
4203 }
4204 }
4205
4206
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(!from_menu)
4207 14 game_mouse();
4208 14 eat_buttons();
4209
4210 14 zc_readrawkey(KEY_ESC);
4211
4212 14 zc_readrawkey(KEY_ENTER);
4213 14 }
4214
4215 //----------------------------------------------------------------
4216
4217 int32_t onNoWalls()
4218 {
4219 cheats_enqueue(Cheat::Walls);
4220 return D_O_K;
4221 }
4222
4223 int32_t onIgnoreSideview()
4224 {
4225 cheats_enqueue(Cheat::IgnoreSideView);
4226 return D_O_K;
4227 }
4228
4229 9286678 int32_t input_idle(bool checkmouse)
4230 {
4231 static int32_t mx, my, mz, mb;
4232
4233
4/6
✓ Branch 0 taken 9286678 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2461637 times.
✓ Branch 3 taken 6825041 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2461637 times.
11748315 if(keypressed() || zc_key_pressed() ||
4234
4/8
✓ Branch 0 taken 2461637 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2461637 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2461637 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2461637 times.
✗ Branch 7 not taken.
2461637 (checkmouse && (mx != mouse_x || my != mouse_y || mz != mouse_z || mb != mouse_b)))
4235 {
4236 6825041 idle_count = 0;
4237
4238
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6825041 times.
6825041 if(active_count < MAX_ACTIVE)
4239 {
4240 6825041 ++active_count;
4241 6825041 }
4242 6825041 }
4243
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2461637 times.
2461637 else if(idle_count < MAX_IDLE)
4244 {
4245 2461637 ++idle_count;
4246 2461637 active_count = 0;
4247 2461637 }
4248
4249 9286678 mx = mouse_x;
4250 9286678 my = mouse_y;
4251 9286678 mz = mouse_z;
4252 9286678 mb = mouse_b;
4253
4254 9286678 return idle_count;
4255 }
4256
4257 int32_t onGoFast()
4258 {
4259 cheats_enqueue(Cheat::Fast);
4260 return D_O_K;
4261 }
4262
4263 int32_t onKillCheat()
4264 {
4265 cheats_enqueue(Cheat::Kill);
4266 return D_O_K;
4267 }
4268
4269 int32_t onSecretsCheat()
4270 {
4271 cheats_enqueue(Cheat::TrigSecrets);
4272 return D_O_K;
4273 }
4274 int32_t onSecretsCheatPerm()
4275 {
4276 cheats_enqueue(Cheat::TrigSecretsPerm);
4277 return D_O_K;
4278 }
4279
4280 int32_t onShowLayer0()
4281 {
4282 show_layer_0 = !show_layer_0;
4283 return D_O_K;
4284 }
4285 int32_t onShowLayer1()
4286 {
4287 show_layer_1 = !show_layer_1;
4288 return D_O_K;
4289 }
4290 int32_t onShowLayer2()
4291 {
4292 show_layer_2 = !show_layer_2;
4293 return D_O_K;
4294 }
4295 int32_t onShowLayer3()
4296 {
4297 show_layer_3 = !show_layer_3;
4298 return D_O_K;
4299 }
4300 int32_t onShowLayer4()
4301 {
4302 show_layer_4 = !show_layer_4;
4303 return D_O_K;
4304 }
4305 int32_t onShowLayer5()
4306 {
4307 show_layer_5 = !show_layer_5;
4308 return D_O_K;
4309 }
4310 int32_t onShowLayer6()
4311 {
4312 show_layer_6 = !show_layer_6;
4313 return D_O_K;
4314 }
4315 int32_t onShowLayerO()
4316 {
4317 show_layer_over=!show_layer_over;
4318 return D_O_K;
4319 }
4320 int32_t onShowLayerP()
4321 {
4322 show_layer_push=!show_layer_push;
4323 return D_O_K;
4324 }
4325 int32_t onShowLayerS()
4326 {
4327 show_sprites=!show_sprites;
4328 return D_O_K;
4329 }
4330 int32_t onShowLayerF()
4331 {
4332 show_ffcs=!show_ffcs;
4333 return D_O_K;
4334 }
4335 int32_t onShowLayerW()
4336 {
4337 show_walkflags=!show_walkflags;
4338 if(show_walkflags)
4339 show_effectflags = false;
4340 return D_O_K;
4341 }
4342 int32_t onShowLayerE()
4343 {
4344 show_effectflags=!show_effectflags;
4345 if(show_effectflags)
4346 show_walkflags = false;
4347 return D_O_K;
4348 }
4349 int32_t onShowFFScripts()
4350 {
4351 show_ff_scripts=!show_ff_scripts;
4352 return D_O_K;
4353 }
4354 int32_t onShowHitboxes()
4355 {
4356 show_hitboxes=!show_hitboxes;
4357 return D_O_K;
4358 }
4359 int32_t onShowInfoOpacity()
4360 {
4361 info_opacity = vbound(getnumber("Debug Info Opacity",info_opacity),0,255);
4362 zc_set_config("zc","debug_info_opacity",info_opacity);
4363 return D_O_K;
4364 }
4365
4366 int32_t onLightSwitch()
4367 {
4368 cheats_enqueue(Cheat::Light);
4369 return D_O_K;
4370 }
4371
4372 int32_t onGoTo();
4373 int32_t onGoToComplete();
4374
4375 9286678 bool handle_close_btn_quit()
4376 {
4377
1/2
✓ Branch 0 taken 9286678 times.
✗ Branch 1 not taken.
9286678 if(close_button_quit)
4378 {
4379 close_button_quit=false;
4380 f_Quit(qEXIT);
4381 }
4382 9286678 return (exiting_program = Quit==qEXIT);
4383 }
4384
4385 9286678 void syskeys()
4386 {
4387 9286678 update_system_keys();
4388
4389 int32_t oldtitle_version;
4390
4391 9286678 poll_joystick();
4392
4393 9286678 handle_close_btn_quit();
4394
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9286678 times.
9286678 if(Quit == qEXIT) return;
4395
4396
2/10
✓ Branch 0 taken 9286678 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 9286678 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
9286678 if(rMbtn() || (gui_mouse_b() && !mouse_down && ClickToFreeze &&!disableClickToFreeze))
4397 {
4398 System();
4399 }
4400
4401 9286678 mouse_down=gui_mouse_b();
4402
4403
1/2
✓ Branch 0 taken 9286678 times.
✗ Branch 1 not taken.
9286678 if(zc_read_system_key(KEY_F1))
4404 {
4405 if(zc_get_system_key(KEY_ZC_LCONTROL) || zc_get_system_key(KEY_ZC_RCONTROL))
4406 {
4407 halt=!halt;
4408 //zinit.subscreen=(zinit.subscreen+1)%ssdtMAX;
4409 }
4410 else
4411 {
4412 Throttlefps=!Throttlefps;
4413 zc_set_config(cfg_sect,"throttlefps", (int32_t)Throttlefps);
4414 }
4415 }
4416
4417 // if(zc_readkey(KEY_F1)) Vsync=!Vsync;
4418 /*
4419 if(zc_readkey(KEY_F1)) set_bit(QHeader.rules4,qr4_NEWENEMYTILES,
4420 1-((get_bit(QHeader.rules4,qr4_NEWENEMYTILES))));
4421 */
4422
4423
1/2
✓ Branch 0 taken 9286678 times.
✗ Branch 1 not taken.
9286678 if(zc_read_system_key(KEY_F2))
4424 {
4425 ShowFPS=!ShowFPS;
4426 zc_set_config(cfg_sect,"showfps",(int32_t)ShowFPS);
4427 }
4428
4429
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 9286678 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
9286678 if(zc_read_system_key(KEY_F3) && Playing) Paused=!Paused;
4430
4431
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 9286678 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
9286678 if(zc_read_system_key(KEY_F4) && Playing)
4432 {
4433 Paused=true;
4434 Advance=true;
4435 }
4436
4437
1/2
✓ Branch 0 taken 9286678 times.
✗ Branch 1 not taken.
9286678 if(zc_read_system_key(KEY_F6)) onTryQuit();
4438
4439 #ifndef ALLEGRO_MACOSX
4440
1/2
✓ Branch 0 taken 9286678 times.
✗ Branch 1 not taken.
9286678 if(zc_read_system_key(KEY_F9)) f_Quit(qRESET);
4441
4442
1/2
✓ Branch 0 taken 9286678 times.
✗ Branch 1 not taken.
9286678 if(zc_read_system_key(KEY_F10)) f_Quit(qEXIT);
4443 #else
4444 if(zc_read_system_key(KEY_F7)) f_Quit(qRESET);
4445
4446 if(zc_read_system_key(KEY_F8)) f_Quit(qEXIT);
4447 #endif
4448
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 9286678 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
9286678 if(zc_read_system_key(KEY_F5)&&(Playing && currscr<128 && DMaps[currdmap].flags&dmfVIEWMAP)) onSaveMapPic();
4449
4450
1/2
✓ Branch 0 taken 9286678 times.
✗ Branch 1 not taken.
9286678 if (zc_read_system_key(KEY_F12))
4451 {
4452 onSnapshot();
4453 }
4454
4455
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 9286678 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
9286678 if(debug_enabled && zc_read_system_key(KEY_TAB))
4456 set_debug(!get_debug());
4457
4458
1/2
✓ Branch 0 taken 9286678 times.
✗ Branch 1 not taken.
9286678 if(CheatModifierKeys())
4459 {
4460 for(Cheat c = (Cheat)1; c < Cheat::Last; c = (Cheat)(c+1))
4461 {
4462 if(!bindable_cheat(c))
4463 continue;
4464 if(get_debug() || cheat >= cheat_lvl(c))
4465 {
4466 if(checkcheat(c))
4467 cheats_hit_bind(c);
4468 }
4469 }
4470 }
4471
4472
1/2
✓ Branch 0 taken 9286678 times.
✗ Branch 1 not taken.
9286678 if(volkeys)
4473 {
4474 if(zc_read_system_key(KEY_PGUP)) master_volume(-1,midi_volume+8);
4475
4476 if(zc_read_system_key(KEY_PGDN)) master_volume(-1,midi_volume==255?248:midi_volume-8);
4477
4478 if(zc_read_system_key(KEY_HOME)) master_volume(digi_volume+8,-1);
4479
4480 if(zc_read_system_key(KEY_END)) master_volume(digi_volume==255?248:digi_volume-8,-1);
4481 }
4482
4483
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 9286678 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
9286678 if(!get_debug() || !SystemKeys || replay_is_replaying())
4484 9286678 goto bottom;
4485
4486 if(zc_readkey(KEY_D))
4487 {
4488 details = !details;
4489 rectfill(screen,0,0,319,7,BLACK);
4490 rectfill(screen,0,8,31,239,BLACK);
4491 rectfill(screen,288,8,319,239,BLACK);
4492 rectfill(screen,32,232,287,239,BLACK);
4493 }
4494
4495 if(zc_readkey(KEY_P)) Paused=!Paused;
4496
4497 //if(zc_readkey(KEY_P)) centerHero();
4498 if(zc_readkey(KEY_A))
4499 {
4500 Paused=true;
4501 Advance=true;
4502 }
4503
4504 if(zc_readkey(KEY_G)) db=(db==999)?0:999;
4505 #ifndef ALLEGRO_MACOSX
4506 if(zc_readkey(KEY_F8)) Showpal=!Showpal;
4507
4508 if(zc_readkey(KEY_F7))
4509 {
4510 Matrix(ss_speed, ss_density, 0);
4511 game_pal();
4512 }
4513 #else
4514 // The reason these are different on Mac in the first place is that
4515 // the OS doesn't let us use F9 and F10...
4516 if(zc_readkey(KEY_F10)) Showpal=!Showpal;
4517
4518 if(zc_readkey(KEY_F9))
4519 {
4520 Matrix(ss_speed, ss_density, 0);
4521 game_pal();
4522 }
4523 #endif
4524 if(zc_readkey(KEY_PLUS_PAD) || zc_readkey(KEY_EQUALS))
4525 {
4526 //change containers
4527 if(zc_getkey(KEY_ZC_LCONTROL) || zc_getkey(KEY_ZC_RCONTROL))
4528 {
4529 //magic containers
4530 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4531 {
4532 game->set_maxmagic(zc_min(game->get_maxmagic()+game->get_mp_per_block(),game->get_mp_per_block()*8));
4533 }
4534 else
4535 {
4536 game->set_maxlife(zc_min(game->get_maxlife()+game->get_hp_per_heart(),game->get_hp_per_heart()*24));
4537 }
4538 }
4539 else
4540 {
4541 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4542 {
4543 game->set_magic(zc_min(game->get_magic()+1,game->get_maxmagic()));
4544 }
4545 else
4546 {
4547 game->set_life(zc_min(game->get_life()+1,game->get_maxlife()));
4548 }
4549 }
4550 }
4551
4552 if(zc_readkey(KEY_MINUS_PAD) || zc_readkey(KEY_MINUS))
4553 {
4554 //change containers
4555 if(zc_getkey(KEY_ZC_LCONTROL) || zc_getkey(KEY_ZC_RCONTROL))
4556 {
4557 //magic containers
4558 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4559 {
4560 game->set_maxmagic(zc_max(game->get_maxmagic()-game->get_mp_per_block(),0));
4561 game->set_magic(zc_min(game->get_maxmagic(), game->get_magic()));
4562 //heart containers
4563 }
4564 else
4565 {
4566 game->set_maxlife(zc_max(game->get_maxlife()-game->get_hp_per_heart(),game->get_hp_per_heart()));
4567 game->set_life(zc_min(game->get_maxlife(), game->get_life()));
4568 }
4569 }
4570 else
4571 {
4572 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4573 {
4574 game->set_magic(zc_max(game->get_magic()-1,0));
4575 }
4576 else
4577 {
4578 game->set_life(zc_max(game->get_life()-1,0));
4579 }
4580 }
4581 }
4582
4583 if(zc_readkey(KEY_COMMA)) jukebox(currmidi-1);
4584
4585 if(zc_readkey(KEY_STOP)) jukebox(currmidi+1);
4586
4587 verifyBothWeapons();
4588
4589 bottom:
4590
4591
1/2
✓ Branch 0 taken 9286678 times.
✗ Branch 1 not taken.
9286678 if(input_idle(true) > after_time())
4592 {
4593 Matrix(ss_speed, ss_density, 0);
4594 game_pal();
4595 }
4596 9286678 }
4597
4598 708283 void checkQuitKeys()
4599 {
4600 #ifndef ALLEGRO_MACOSX
4601
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 708283 times.
708283 if(key[KEY_F9]) f_Quit(qRESET);
4602
4603
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 708283 times.
708283 if(key[KEY_F10]) f_Quit(qEXIT);
4604 #else
4605 if(key[KEY_F7]) f_Quit(qRESET);
4606
4607 if(key[KEY_F8]) f_Quit(qEXIT);
4608 #endif
4609 708283 }
4610
4611 9286678 bool CheatModifierKeys()
4612 {
4613 // Cheats are replayed via the X cheat step, no need to check for keyboard input
4614 // to trigger cheats.
4615
1/2
✓ Branch 0 taken 9286678 times.
✗ Branch 1 not taken.
9286678 if (replay_is_replaying())
4616 9286678 return false;
4617
4618 if ( ( cheat_modifier_keys[0] > 0 && key[cheat_modifier_keys[0]] ) ||
4619 ( cheat_modifier_keys[1] > 0 && key[cheat_modifier_keys[1]] ) ||
4620 (cheat_modifier_keys[0] <= 0 && cheat_modifier_keys[1] <= 0))
4621 {
4622 if ( ( cheat_modifier_keys[2] <= 0 || key[cheat_modifier_keys[2]] ) ||
4623 ( cheat_modifier_keys[3] > 0 && key[cheat_modifier_keys[3]] ) ||
4624 (cheat_modifier_keys[2] <= 0 && cheat_modifier_keys[3] <= 0))
4625 {
4626 return true;
4627 }
4628 }
4629 return false;
4630 9286678 }
4631
4632 //99:05:54, for some reason?
4633 #define OLDMAXTIME 21405240
4634 //9000:00:00, the highest even-thousand hour fitting within 32b signed. This is 375 *DAYS*.
4635 #define MAXTIME 1944000000
4636
4637 9286804 void advanceframe(bool allowwavy, bool sfxcleanup, bool allowF6Script)
4638 {
4639
1/2
✓ Branch 0 taken 9286804 times.
✗ Branch 1 not taken.
9286804 if(zcmusic!=NULL)
4640 {
4641 zcmusic_poll();
4642 }
4643 9286804 zcmixer_update(zcmixer, emusic_volume, FFCore.usr_music_volume, get_qr(qr_OLD_SCRIPT_VOLUME));
4644
4645 9286804 updatescr(allowwavy);
4646
4647 9286804 Advance=false;
4648
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 9286804 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 9286804 times.
9286804 while(Paused && !Advance && !Quit)
4649 {
4650 // have to call this, otherwise we'll get an infinite loop
4651 syskeys();
4652 if(allowF6Script)
4653 {
4654 FFCore.runF6Engine();
4655 }
4656 throttleFPS();
4657
4658 #ifdef _WIN32
4659
4660 if(use_dwm_flush)
4661 {
4662 do_DwmFlush();
4663 }
4664
4665 #endif
4666
4667 // to keep music playing
4668 if(zcmusic!=NULL)
4669 {
4670 zcmusic_poll();
4671 }
4672
4673 update_hw_screen();
4674 }
4675
4676
2/2
✓ Branch 0 taken 9286692 times.
✓ Branch 1 taken 112 times.
9286804 if(Quit)
4677 112 return;
4678
4679
3/4
✓ Branch 0 taken 8985563 times.
✓ Branch 1 taken 301129 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 8985563 times.
9286692 if(Playing && game->get_time()<unsigned(get_qr(qr_GREATER_MAX_TIME) ? MAXTIME : OLDMAXTIME))
4680 8985563 game->change_time(1);
4681
4682 // Many mistakes have been make re: inputs, and we are stuck with many replays relying on those mistakes.
4683
4684 9286692 bool should_reset_down_state = !get_qr(qr_BROKEN_INPUT_DOWN_STATE);
4685
2/2
✓ Branch 0 taken 19895 times.
✓ Branch 1 taken 9266797 times.
9286692 if (replay_version_check(0, 16))
4686 9266797 should_reset_down_state = replay_version_check(11, 16);
4687
2/2
✓ Branch 0 taken 6949680 times.
✓ Branch 1 taken 2337012 times.
9286692 if (should_reset_down_state)
4688 {
4689
2/2
✓ Branch 0 taken 42066216 times.
✓ Branch 1 taken 2337012 times.
44403228 for (int i = 0; i < ZC_CONTROL_STATES; i++)
4690 42066216 down_control_states[i] = raw_control_state[i];
4691 2337012 }
4692
4693
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 9286678 times.
9286692 if (replay_is_active())
4694 {
4695
2/2
✓ Branch 0 taken 1270449 times.
✓ Branch 1 taken 8016229 times.
9286678 if (replay_version_check(3))
4696 8016229 replay_poll();
4697
4698
4/4
✓ Branch 0 taken 6946098 times.
✓ Branch 1 taken 2340580 times.
✓ Branch 2 taken 100535 times.
✓ Branch 3 taken 6845563 times.
9286678 if (replay_version_check(11) || replay_version_check(6, 8))
4699 2441115 replay_peek_input();
4700 9286678 }
4701
4702 9286692 load_control_called_this_frame = false;
4703
4704 9286692 poll_keyboard();
4705 9286692 update_keys();
4706
4707 9286692 ++frame;
4708
4709
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 9286678 times.
9286692 if (replay_is_replaying())
4710 9286678 replay_do_cheats();
4711 9286692 syskeys();
4712
4713 // The mouse variables can change from the mouse thread at anytime during a frame,
4714 // so save the result at the start so that replaying is consistent.
4715 9286692 script_mouse_x = gui_mouse_x();
4716 9286692 script_mouse_y = gui_mouse_y();
4717 9286692 script_mouse_z = mouse_z;
4718 9286692 script_mouse_b = mouse_b;
4719
4720 // Cheats used via the System menu (called by syskeys) will call cheats_enqueue. syskeys
4721 // is called just above, and in the paused loop above, so the queue-and-defer-slightly
4722 // approach here means it doesn't matter which call adds the cheat.
4723 9286692 cheats_execute_queued();
4724
4725
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 9286678 times.
9286692 if (replay_is_replaying())
4726 9286678 replay_peek_quit();
4727
2/2
✓ Branch 0 taken 9286678 times.
✓ Branch 1 taken 14 times.
9286692 if (GameFlags & GAMEFLAG_TRYQUIT)
4728 14 replay_step_quit(0);
4729
2/2
✓ Branch 0 taken 2934 times.
✓ Branch 1 taken 9283758 times.
9286692 if(allowF6Script)
4730 9283758 FFCore.runF6Engine();
4731
2/2
✓ Branch 0 taken 300 times.
✓ Branch 1 taken 9286392 times.
9286692 if (Quit)
4732 300 replay_step_quit(Quit);
4733 // Someday... maybe install a Turbo button here?
4734 9286692 throttleFPS();
4735
4736 #ifdef _WIN32
4737
4738 if(use_dwm_flush)
4739 {
4740 do_DwmFlush();
4741 }
4742
4743 #endif
4744
4745 //textprintf_ex(screen,font,0,72,254,BLACK,"%d %d", lastentrance, lastentrance_dmap);
4746
2/2
✓ Branch 0 taken 68758 times.
✓ Branch 1 taken 9217934 times.
9286692 if(sfxcleanup)
4747 9217934 sfx_cleanup();
4748
4749 9286692 jit_poll();
4750
4751 #ifdef __EMSCRIPTEN__
4752 // Yield the main thread back to the browser occasionally.
4753 if (is_headless())
4754 {
4755 static int rate = 10000;
4756 static int force_yield = rate;
4757 if (force_yield++ >= rate)
4758 {
4759 force_yield = 0;
4760 emscripten_sleep(0);
4761 }
4762 }
4763 #endif
4764
4765
4/6
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 9286576 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 116 times.
✓ Branch 4 taken 116 times.
✗ Branch 5 not taken.
9286692 static bool test_mode_auto_restart = zc_get_config("zeldadx", "test_mode_auto_restart", false);
4766
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 9286692 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
9286692 if (zqtesting_mode && test_mode_auto_restart)
4767 {
4768 static auto last_write_time = fs::last_write_time(qstpath);
4769 static auto last_check = std::chrono::system_clock::now();
4770
4771 if (std::chrono::system_clock::now() - last_check > 200ms)
4772 {
4773 last_check = std::chrono::system_clock::now();
4774 auto write_time = fs::last_write_time(qstpath);
4775 if (last_write_time != write_time)
4776 {
4777 last_write_time = write_time;
4778 disableClickToFreeze = false;
4779 Quit = qRESET;
4780 replay_quit();
4781 }
4782 }
4783 }
4784 9286804 }
4785
4786 101 void zapout()
4787 {
4788 101 set_clip_rect(scrollbuf, 0, 0, scrollbuf->w, scrollbuf->h);
4789 101 blit(framebuf,scrollbuf,0,0,256,0,256,224);
4790
4791 101 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
4792 101 script_drawing_commands.Clear();
4793
4794 // zap out
4795
2/2
✓ Branch 0 taken 101 times.
✓ Branch 1 taken 2424 times.
2525 for(int32_t i=1; i<=24; i++)
4796 {
4797 2424 draw_fuzzy(i);
4798 2424 advanceframe(true);
4799
4800
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2424 times.
2424 if(Quit)
4801 {
4802 break;
4803 }
4804 2424 }
4805 101 }
4806
4807 101 void zapin()
4808 {
4809 101 FFCore.warpScriptCheck();
4810 101 draw_screen(tmpscr);
4811 101 set_clip_rect(scrollbuf, 0, 0, scrollbuf->w, scrollbuf->h);
4812 //put_passive_subscr(framebuf,0,passive_subscreen_offset,false,sspUP);
4813 101 blit(framebuf,scrollbuf,0,0,256,0,256,224);
4814
4815 // zap out
4816 101 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
4817
2/2
✓ Branch 0 taken 101 times.
✓ Branch 1 taken 2424 times.
2525 for(int32_t i=24; i>=1; i--)
4818 {
4819 2424 draw_fuzzy(i);
4820 2424 advanceframe(true);
4821
4822
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2424 times.
2424 if(Quit)
4823 {
4824 break;
4825 }
4826 2424 }
4827 101 }
4828
4829
4830 65 void wavyout(bool showhero)
4831 {
4832 65 draw_screen(tmpscr, showhero);
4833 //put_passive_subscr(framebuf,0,passive_subscreen_offset,false,sspUP);
4834
4835 65 BITMAP *wavebuf = create_bitmap_ex(8,288,224);
4836 65 clear_to_color(wavebuf,0);
4837 65 blit(framebuf,wavebuf,0,0,16,0,256,224);
4838
4839 static PALETTE wavepal;
4840
4841 int32_t ofs;
4842 65 int32_t amplitude=8;
4843
4844 65 int32_t wavelength=4;
4845 65 double palpos=0, palstep=4, palstop=126;
4846
4847 65 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
4848
2/2
✓ Branch 0 taken 65 times.
✓ Branch 1 taken 2730 times.
2795 for(int32_t i=0; i<168; i+=wavelength)
4849 {
4850
2/2
✓ Branch 0 taken 698880 times.
✓ Branch 1 taken 2730 times.
701610 for(int32_t l=0; l<256; l++)
4851 {
4852 698880 wavepal[l].r=vbound(int32_t(RAMpal[l].r+((palpos/palstop)*(63-RAMpal[l].r))),0,63);
4853 698880 wavepal[l].g=vbound(int32_t(RAMpal[l].g+((palpos/palstop)*(63-RAMpal[l].g))),0,63);
4854 698880 wavepal[l].b=vbound(int32_t(RAMpal[l].b+((palpos/palstop)*(63-RAMpal[l].b))),0,63);
4855 698880 }
4856
4857 2730 palpos+=palstep;
4858
4859
1/2
✓ Branch 0 taken 2730 times.
✗ Branch 1 not taken.
2730 if(palpos>=0)
4860 {
4861 2730 hw_palette = &wavepal;
4862 2730 update_hw_pal = true;
4863 2730 }
4864 else
4865 {
4866 hw_palette = &RAMpal;
4867 update_hw_pal = true;
4868 }
4869
4870
2/2
✓ Branch 0 taken 458640 times.
✓ Branch 1 taken 2730 times.
461370 for(int32_t j=0; j+playing_field_offset<224; j++)
4871 {
4872
2/2
✓ Branch 0 taken 117411840 times.
✓ Branch 1 taken 458640 times.
117870480 for(int32_t k=0; k<256; k++)
4873 {
4874 117411840 ofs=0;
4875
4876
4/4
✓ Branch 0 taken 57308160 times.
✓ Branch 1 taken 60103680 times.
✓ Branch 2 taken 28654080 times.
✓ Branch 3 taken 28654080 times.
117411840 if((j<i)&&(j&1))
4877 {
4878 28654080 ofs=int32_t(zc::math::Sin((double(i+j)*2*PI/168.0))*amplitude);
4879 28654080 }
4880
4881 117411840 framebuf->line[j+playing_field_offset][k]=wavebuf->line[j+playing_field_offset][k+ofs+16];
4882 117411840 }
4883 458640 }
4884
4885 2730 advanceframe(true);
4886
4887 // animate_combos();
4888
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2730 times.
2730 if(Quit)
4889 break;
4890 2730 }
4891
4892 65 destroy_bitmap(wavebuf);
4893 65 }
4894
4895 65 void wavyin()
4896 {
4897 65 draw_screen(tmpscr);
4898 //put_passive_subscr(framebuf,0,passive_subscreen_offset,false,sspUP);
4899
4900 65 BITMAP *wavebuf = create_bitmap_ex(8,288,224);
4901 65 clear_to_color(wavebuf,0);
4902 65 blit(framebuf,wavebuf,0,0,16,0,256,224);
4903
4904 static PALETTE wavepal;
4905
4906 //Breaks dark rooms.
4907 //In any case I don't think we need this, since palette is already loaded in doWarp() (famous last words...) -DD
4908 /*
4909 loadfullpal();
4910 loadlvlpal(DMaps[currdmap].color);
4911 ringcolor(false);
4912 */
4913 65 refreshpal=false;
4914 int32_t ofs;
4915 65 int32_t amplitude=8;
4916 65 int32_t wavelength=4;
4917 65 double palpos=168, palstep=4, palstop=126;
4918
4919 65 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
4920
2/2
✓ Branch 0 taken 65 times.
✓ Branch 1 taken 2730 times.
2795 for(int32_t i=0; i<168; i+=wavelength)
4921 {
4922
2/2
✓ Branch 0 taken 698880 times.
✓ Branch 1 taken 2730 times.
701610 for(int32_t l=0; l<256; l++)
4923 {
4924 698880 wavepal[l].r=vbound(int32_t(RAMpal[l].r+((palpos/palstop)*(63-RAMpal[l].r))),0,63);
4925 698880 wavepal[l].g=vbound(int32_t(RAMpal[l].g+((palpos/palstop)*(63-RAMpal[l].g))),0,63);
4926 698880 wavepal[l].b=vbound(int32_t(RAMpal[l].b+((palpos/palstop)*(63-RAMpal[l].b))),0,63);
4927 698880 }
4928
4929 2730 palpos-=palstep;
4930
4931
1/2
✓ Branch 0 taken 2730 times.
✗ Branch 1 not taken.
2730 if(palpos>=0)
4932 {
4933 2730 hw_palette = &wavepal;
4934 2730 update_hw_pal = true;
4935 2730 }
4936 else
4937 {
4938 hw_palette = &RAMpal;
4939 update_hw_pal = true;
4940 }
4941
4942
2/2
✓ Branch 0 taken 458640 times.
✓ Branch 1 taken 2730 times.
461370 for(int32_t j=0; j+playing_field_offset<224; j++)
4943 {
4944
2/2
✓ Branch 0 taken 117411840 times.
✓ Branch 1 taken 458640 times.
117870480 for(int32_t k=0; k<256; k++)
4945 {
4946 117411840 ofs=0;
4947
4948
4/4
✓ Branch 0 taken 59404800 times.
✓ Branch 1 taken 58007040 times.
✓ Branch 2 taken 30051840 times.
✓ Branch 3 taken 29352960 times.
117411840 if((j<(167-i))&&(j&1))
4949 {
4950 29352960 ofs=int32_t(zc::math::Sin((double(i+j)*2*PI/168.0))*amplitude);
4951 29352960 }
4952
4953 117411840 framebuf->line[j+playing_field_offset][k]=wavebuf->line[j+playing_field_offset][k+ofs+16];
4954 117411840 }
4955 458640 }
4956
4957 2730 advanceframe(true);
4958 // animate_combos();
4959
4960
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2730 times.
2730 if(Quit)
4961 break;
4962 2730 }
4963
4964 65 destroy_bitmap(wavebuf);
4965 65 }
4966
4967 2168 void blackscr(int32_t fcnt,bool showsubscr)
4968 {
4969 2168 reset_pal_cycling();
4970 2168 script_drawing_commands.Clear();
4971
4972 2168 FFCore.warpScriptCheck();
4973 2168 bool showtime = game->should_show_time();
4974
2/2
✓ Branch 0 taken 2168 times.
✓ Branch 1 taken 64970 times.
67138 while(fcnt>0)
4975 {
4976 64970 clear_bitmap(framebuf);
4977
4978
2/2
✓ Branch 0 taken 25080 times.
✓ Branch 1 taken 39890 times.
64970 if(showsubscr)
4979 {
4980 39890 put_passive_subscr(framebuf,0,passive_subscreen_offset,showtime,sspUP);
4981
3/4
✓ Branch 0 taken 39890 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 750 times.
✓ Branch 3 taken 39140 times.
39890 if(get_qr(qr_SCRIPTDRAWSINWARPS) || (get_qr(qr_PASSIVE_SUBSCRIPT_RUNS_WHEN_GAME_IS_FROZEN)))
4982 {
4983 750 do_script_draws(framebuf, tmpscr, 0, playing_field_offset);
4984 750 }
4985 39890 }
4986
4987 64970 advanceframe(true);
4988
4989
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 64970 times.
64970 if(Quit)
4990 break;
4991
4992 64970 --fcnt;
4993 }
4994 2168 }
4995
4996 1012 void openscreen(int32_t shape)
4997 {
4998 1012 reset_pal_cycling();
4999 1012 black_opening_count=0;
5000
5001
3/4
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 912 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 100 times.
1012 if(COOLSCROLL || shape>-1)
5002 {
5003 912 open_black_opening(HeroX()+8, (HeroY()-HeroZ()-HeroFakeZ())+8+playing_field_offset, true, shape);
5004 912 return;
5005 }
5006 else
5007 {
5008 100 Hero.setDontDraw(true);
5009 100 show_subscreen_dmap_dots=false;
5010 100 show_subscreen_numbers=false;
5011 // show_subscreen_items=false;
5012 100 show_subscreen_life=false;
5013 }
5014
5015 100 int32_t x=128;
5016
5017 100 FFCore.warpScriptCheck();
5018
2/2
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 8000 times.
8100 for(int32_t i=0; i<80; i++)
5019 {
5020 8000 draw_screen(tmpscr);
5021 //? draw_screen already draws the subscreen -DD
5022 //put_passive_subscr(framebuf,0,passive_subscreen_offset,false,sspUP);
5023 8000 x=128-(((i*128/80)/8)*8);
5024
5025
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8000 times.
8000 if(x>0)
5026 {
5027 8000 rectfill(framebuf,0,playing_field_offset,x,167+playing_field_offset,0);
5028 8000 rectfill(framebuf,256-x,playing_field_offset,255,167+playing_field_offset,0);
5029 8000 }
5030
5031 8000 advanceframe(true);
5032
5033
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8000 times.
8000 if(Quit)
5034 {
5035 break;
5036 }
5037 8000 }
5038
5039 100 Hero.setDontDraw(false);
5040 100 show_subscreen_items=true;
5041 100 show_subscreen_dmap_dots=true;
5042 1012 }
5043
5044 void closescreen(int32_t shape)
5045 {
5046 reset_pal_cycling();
5047 black_opening_count=0;
5048
5049 if(COOLSCROLL || shape>-1)
5050 {
5051 close_black_opening(HeroX()+8, (HeroY()-HeroZ()-HeroFakeZ())+8+playing_field_offset, true, shape);
5052 return;
5053 }
5054 else
5055 {
5056 Hero.setDontDraw(true);
5057 show_subscreen_dmap_dots=false;
5058 show_subscreen_numbers=false;
5059 // show_subscreen_items=false;
5060 show_subscreen_life=false;
5061 }
5062
5063 int32_t x=128;
5064
5065 FFCore.warpScriptCheck();
5066 for(int32_t i=79; i>=0; --i)
5067 {
5068 draw_screen(tmpscr);
5069 //? draw_screen already draws the subscreen -DD
5070 //put_passive_subscr(framebuf,0,passive_subscreen_offset,false,sspUP);
5071 x=128-(((i*128/80)/8)*8);
5072
5073 if(x>0)
5074 {
5075 rectfill(framebuf,0,playing_field_offset,x,167+playing_field_offset,0);
5076 rectfill(framebuf,256-x,playing_field_offset,255,167+playing_field_offset,0);
5077 }
5078
5079 advanceframe(true);
5080
5081 if(Quit)
5082 {
5083 break;
5084 }
5085 }
5086
5087 Hero.setDontDraw(false);
5088 show_subscreen_items=true;
5089 show_subscreen_dmap_dots=true;
5090 }
5091
5092 179 int32_t TriforceCount()
5093 {
5094 179 int32_t c=0;
5095
5096
2/2
✓ Branch 0 taken 1432 times.
✓ Branch 1 taken 179 times.
1611 for(int32_t i=1; i<=8; i++)
5097
2/2
✓ Branch 0 taken 388 times.
✓ Branch 1 taken 1044 times.
2476 if(game->lvlitems[i]&liTRIFORCE)
5098 1044 ++c;
5099
5100 179 return c;
5101 }
5102
5103 int32_t onCustomGame()
5104 {
5105 int32_t file = getsaveslot();
5106
5107 if(file < 0)
5108 return D_O_K;
5109
5110 bool ret = (custom_game(file)!=0);
5111 return ret ? D_CLOSE : D_O_K;
5112 }
5113
5114 int32_t onContinue()
5115 {
5116 return D_CLOSE;
5117 }
5118
5119 int32_t onEsc() // Unused?? -L
5120 {
5121 return zc_getrawkey(KEY_ESC, true)?D_CLOSE:D_O_K;
5122 }
5123
5124 int32_t onVsync()
5125 {
5126 Throttlefps = !Throttlefps;
5127 zc_set_config(cfg_sect,"throttlefps", (int32_t)Throttlefps);
5128 return D_O_K;
5129 }
5130
5131 int32_t onWinPosSave()
5132 {
5133 SaveWinPos = !SaveWinPos;
5134 zc_set_config(cfg_sect,"save_window_position",(int32_t)SaveWinPos);
5135 return D_O_K;
5136 }
5137 int32_t onIntegerScaling()
5138 {
5139 scaleForceInteger = !scaleForceInteger;
5140 zc_set_config("zeldadx","scaling_force_integer",(int)scaleForceInteger);
5141 return D_O_K;
5142 }
5143 int32_t onStretchGame()
5144 {
5145 stretchGame = !stretchGame;
5146 zc_set_config("zeldadx","stretch_game_area",stretchGame?1:0);
5147 return D_O_K;
5148 }
5149
5150 int32_t onClickToFreeze()
5151 {
5152 ClickToFreeze = !ClickToFreeze;
5153 zc_set_config(cfg_sect,"clicktofreeze", (int32_t)ClickToFreeze);
5154 return D_O_K;
5155 }
5156
5157 int32_t OnSaveZCConfig()
5158 {
5159 if(jwin_alert3(
5160 "Save Configuration",
5161 "Are you sure that you wish to save your present configuration settings?",
5162 "This will overwrite your prior settings!",
5163 NULL,
5164 "&Yes",
5165 "&No",
5166 NULL,
5167 'y',
5168 'n',
5169 0,
5170 get_zc_font(font_lfont)) == 1)
5171 {
5172 save_game_configs();
5173 return D_O_K;
5174 }
5175 else return D_O_K;
5176 }
5177
5178 int32_t OnnClearQuestDir()
5179 {
5180 if(jwin_alert3(
5181 "Clear Current Directory Cache",
5182 "Are you sure that you wish to clear the current cached directory?",
5183 "This will default the current directory to the ROOT for this instance of ZC Player!",
5184 NULL,
5185 "&Yes",
5186 "&No",
5187 NULL,
5188 'y',
5189 'n',
5190 0,
5191 get_zc_font(font_lfont)) == 1)
5192 {
5193 zc_set_config("zeldadx","win_qst_dir","");
5194 flush_config_file();
5195 strcpy(qstdir,"");
5196 #ifdef __EMSCRIPTEN__
5197 em_sync_fs();
5198 #endif
5199 return D_O_K;
5200 }
5201 else return D_O_K;
5202 }
5203
5204
5205 int32_t onConsoleZASM()
5206 {
5207 if ( !zasm_debugger )
5208 {
5209 AlertDialog("WARNING: ZASM Debugger",
5210 "Enabling this will open the ZASM Debugger Console"
5211 "\nThis will likely grind ZC to a halt with lag."
5212 "\nTo make any use of this, it is suggested that you read"
5213 "\nthe documentation for 'void Breakpoint(char[] string);'"
5214 " in 'ZScript_Additions.txt'"
5215 "\nThis is not recommended for normal users,"
5216 " and is only intended for ZC developers,"
5217 "\nor quest developers coding directly in ZASM"
5218 "\nAre you sure that you wish to open the ZASM Debugger?",
5219 [&](bool ret,bool)
5220 {
5221 if(ret)
5222 {
5223 FFCore.ZASMPrint(true);
5224 }
5225 }).show();
5226 return D_O_K;
5227 }
5228 else
5229 {
5230 FFCore.ZASMPrint(false);
5231 return D_O_K;
5232 }
5233 }
5234
5235
5236 int32_t onConsoleZScript()
5237 {
5238 if ( !zscript_debugger )
5239 {
5240 AlertDialog("ZScript Debugger",
5241 "Enabling this will open the ZScript Debugger Console"
5242 "\nThis will display any messages logged by scripts,"
5243 " including script errors."
5244 "\nAre you sure that you wish to open the ZScript Debugger?",
5245 [&](bool ret,bool)
5246 {
5247 if(ret)
5248 {
5249 FFCore.ZScriptConsole(true);
5250 }
5251 }).show();
5252 return D_O_K;
5253 }
5254 else
5255 {
5256 FFCore.ZScriptConsole(false);
5257 return D_O_K;
5258 }
5259 }
5260
5261 int32_t onClrConsoleOnReload()
5262 {
5263 clearConsoleOnReload = !clearConsoleOnReload;
5264 zc_set_config("CONSOLE","clear_console_on_reload",clearConsoleOnReload?1:0);
5265 return D_O_K;
5266 }
5267 int32_t onClrConsoleOnLoad()
5268 {
5269 clearConsoleOnLoad = !clearConsoleOnLoad;
5270 zc_set_config("CONSOLE","clear_console_on_load",clearConsoleOnLoad?1:0);
5271 return D_O_K;
5272 }
5273
5274
5275 int32_t onFrameSkip()
5276 {
5277 FrameSkip = !FrameSkip;
5278 return D_O_K;
5279 }
5280
5281 int32_t onSaveDragResize()
5282 {
5283 SaveDragResize = !SaveDragResize;
5284 zc_set_config(cfg_sect,"save_drag_resize",(int32_t)SaveDragResize);
5285 return D_O_K;
5286 }
5287
5288 int32_t onDragAspect()
5289 {
5290 DragAspect = !DragAspect;
5291 zc_set_config(cfg_sect,"drag_aspect",(int32_t)DragAspect);
5292 return D_O_K;
5293 }
5294
5295 int32_t onTransLayers()
5296 {
5297 TransLayers = !TransLayers;
5298 zc_set_config(cfg_sect,"translayers",(int32_t)TransLayers);
5299 return D_O_K;
5300 }
5301
5302 int32_t onNESquit()
5303 {
5304 NESquit = !NESquit;
5305 zc_set_config(cfg_sect,"fastquit",(int32_t)NESquit);
5306 return D_O_K;
5307 }
5308
5309 int32_t onVolKeys()
5310 {
5311 volkeys = !volkeys;
5312 zc_set_config(sfx_sect,"volkeys",(int32_t)volkeys);
5313 return D_O_K;
5314 }
5315
5316 int32_t onShowFPS()
5317 {
5318 ShowFPS = !ShowFPS;
5319 zc_set_config(cfg_sect,"showfps",(int32_t)ShowFPS);
5320 return D_O_K;
5321 }
5322
5323 1095828004 bool is_Fkey(int32_t k)
5324 {
5325
2/2
✓ Branch 0 taken 111440136 times.
✓ Branch 1 taken 984387868 times.
1095828004 switch(k)
5326 {
5327 case KEY_F1:
5328 case KEY_F2:
5329 case KEY_F3:
5330 case KEY_F4:
5331 case KEY_F5:
5332 case KEY_F6:
5333 case KEY_F7:
5334 case KEY_F8:
5335 case KEY_F9:
5336 case KEY_F10:
5337 case KEY_F11:
5338 case KEY_F12:
5339 111440136 return true;
5340 }
5341
5342 984387868 return false;
5343 1095828004 }
5344
5345 void kb_getkey(DIALOG *d);
5346
5347 //Used by all keyboard key settings dialogues.
5348 void kb_clearjoystick(DIALOG *d)
5349 {
5350 d->flags|=D_SELECTED;
5351
5352 jwin_button_proc(MSG_DRAW,d,0);
5353 jwin_draw_win(gui_bmp, (gui_bmp->w-160)/2, (gui_bmp->h-48)/2, 168, 48, FR_WIN);
5354 // text_mode(vc(11));
5355 textout_centre_ex(gui_bmp, font, "Press any key to clear", gui_bmp->w/2, gui_bmp->h/2 - 8, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5356 textout_centre_ex(gui_bmp, font, "ESC to cancel", gui_bmp->w/2, gui_bmp->h/2, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5357
5358 update_hw_screen(true);
5359
5360 clear_keybuf();
5361 int32_t k = next_press_key();
5362 clear_keybuf();
5363
5364 //shnarf
5365 //47=f1
5366 //59=esc
5367 // if(k>0 && k<123 && !((k>46)&&(k<60)))
5368 // *((int32_t*)d->dp3) = k;
5369 if ( k != 59 ) *((int32_t*)d->dp3) = 0;
5370
5371
5372 d->flags&=~D_SELECTED;
5373 }
5374
5375 //Clears key to 0.
5376 //Used by all keyboard key settings dialogues.
5377 void kb_clearkey(DIALOG *d);
5378
5379 int32_t d_j_clearbutton_proc(int32_t msg,DIALOG *d,int32_t c)
5380 {
5381 switch(msg)
5382 {
5383 case MSG_KEY:
5384 case MSG_CLICK:
5385
5386 kb_clearjoystick(d);
5387
5388 while(gui_mouse_b())
5389 {
5390 clear_keybuf();
5391 rest(1);
5392 }
5393
5394 return D_REDRAW;
5395 }
5396
5397 return jwin_button_proc(msg,d,c);
5398 }
5399
5400 int32_t d_kbutton_proc(int32_t msg,DIALOG *d,int32_t c);
5401 //Only used in keyboard settings dialogues to clear keys.
5402 int32_t d_k_clearbutton_proc(int32_t msg,DIALOG *d,int32_t c);
5403
5404 void j_getbtn(DIALOG *d)
5405 {
5406 d->flags|=D_SELECTED;
5407 jwin_button_proc(MSG_DRAW,d,0);
5408 jwin_draw_win(screen, (screen->w-160)/2, (screen->h-48)/2, 160, 48, FR_WIN);
5409 // text_mode(vc(11));
5410 int32_t y = screen->h/2 - 12;
5411 textout_centre_ex(screen, font, "Press a button", screen->w/2, y, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5412 textout_centre_ex(screen, font, "ESC to cancel", screen->w/2, y+8, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5413 textout_centre_ex(screen, font, "SPACE to disable", screen->w/2, y+16, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5414
5415 update_hw_screen(true);
5416
5417 int32_t b = next_joy_input(true);
5418
5419 if(b>=0)
5420 *((int32_t*)d->dp3) = b;
5421
5422 d->flags&=~D_SELECTED;
5423
5424 if (player)
5425 player->joy_on = TRUE;
5426 }
5427
5428 void j_getstick(DIALOG *d)
5429 {
5430 d->flags|=D_SELECTED;
5431 jwin_button_proc(MSG_DRAW,d,0);
5432 jwin_draw_win(screen, (screen->w-160)/2, (screen->h-48)/2, 160, 48, FR_WIN);
5433 // text_mode(vc(11));
5434 int32_t y = screen->h/2 - 12;
5435 textout_centre_ex(screen, font, "Move a stick (or DPAD)", screen->w/2, y, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5436 textout_centre_ex(screen, font, "ESC to cancel", screen->w/2, y+8, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5437 textout_centre_ex(screen, font, "SPACE to disable", screen->w/2, y+16, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5438
5439 update_hw_screen(true);
5440
5441 int32_t b = next_joy_input(false);
5442
5443 if(b>=0)
5444 *((int32_t*)d->dp3) = b;
5445
5446 d->flags&=~D_SELECTED;
5447
5448 if (player)
5449 player->joy_on = TRUE;
5450 }
5451
5452 int32_t d_jbutton_proc(int32_t msg,DIALOG *d,int32_t c)
5453 {
5454 switch(msg)
5455 {
5456 case MSG_KEY:
5457 case MSG_CLICK:
5458
5459 j_getbtn(d);
5460
5461 while(gui_mouse_b()) {
5462 rest(1);
5463 clear_keybuf();
5464 }
5465
5466 return D_REDRAW;
5467 }
5468
5469 return jwin_button_proc(msg,d,c);
5470 }
5471
5472 int32_t d_jstick_proc(int32_t msg,DIALOG *d,int32_t c)
5473 {
5474 switch(msg)
5475 {
5476 case MSG_KEY:
5477 case MSG_CLICK:
5478
5479 j_getstick(d);
5480
5481 while(gui_mouse_b()) {
5482 rest(1);
5483 clear_keybuf();
5484 }
5485
5486 return D_REDRAW;
5487 }
5488
5489 return jwin_button_proc(msg,d,c);
5490 }
5491
5492 //shnarf
5493 extern const char *key_str[];
5494 std::string get_keystr(int key);
5495
5496 const char *pan_str[4] = { "MONO", " 1/2", " 3/4", "FULL" };
5497 //extern int32_t zcmusic_bufsz;
5498
5499 static char str_a[80],str_b[80],str_s[80],str_m[80],str_l[80],str_r[80],str_p[80],str_ex1[80],str_ex2[80],str_ex3[80],str_ex4[80],
5500 str_leftmod1[80],str_leftmod2[80],str_rightmod1[80],str_rightmod2[80], str_left[80], str_right[80], str_up[80], str_down[80],
5501 str_primary_stick[80], str_secondary_stick[80];
5502
5503 int32_t d_stringloader(int32_t msg,DIALOG *d,int32_t c)
5504 {
5505 //these are here to bypass compiler warnings about unused arguments
5506 c=c;
5507
5508 if(msg==MSG_DRAW)
5509 {
5510 switch(d->w)
5511 {
5512 case 0:
5513 sprintf(str_a,"%03d\n%s",Akey,key_str[Akey]);
5514 sprintf(str_b,"%03d\n%s",Bkey,key_str[Bkey]);
5515 sprintf(str_s,"%03d\n%s",Skey,key_str[Skey]);
5516 sprintf(str_l,"%03d\n%s",Lkey,key_str[Lkey]);
5517 sprintf(str_r,"%03d\n%s",Rkey,key_str[Rkey]);
5518 sprintf(str_p,"%03d\n%s",Pkey,key_str[Pkey]);
5519 sprintf(str_ex1,"%03d\n%s",Exkey1,key_str[Exkey1]);
5520 sprintf(str_ex2,"%03d\n%s",Exkey2,key_str[Exkey2]);
5521 sprintf(str_ex3,"%03d\n%s",Exkey3,key_str[Exkey3]);
5522 sprintf(str_ex4,"%03d\n%s",Exkey4,key_str[Exkey4]);
5523 sprintf(str_up,"%03d\n%s",DUkey,key_str[DUkey]);
5524 sprintf(str_down,"%03d\n%s",DDkey,key_str[DDkey]);
5525 sprintf(str_left,"%03d\n%s",DLkey,key_str[DLkey]);
5526 sprintf(str_right,"%03d\n%s",DRkey,key_str[DRkey]);
5527 sprintf(str_leftmod1,"%03d\n%s",cheat_modifier_keys[0],key_str[cheat_modifier_keys[0]]);
5528 sprintf(str_leftmod2,"%03d\n%s",cheat_modifier_keys[1],key_str[cheat_modifier_keys[1]]);
5529 sprintf(str_rightmod1,"%03d\n%s",cheat_modifier_keys[2],key_str[cheat_modifier_keys[2]]);
5530 sprintf(str_rightmod2,"%03d\n%s",cheat_modifier_keys[3],key_str[cheat_modifier_keys[3]]);
5531 break;
5532
5533 case 1:
5534 sprintf(str_a,"%03d\n%s",Abtn,joybtn_name(Abtn));
5535 sprintf(str_b,"%03d\n%s",Bbtn,joybtn_name(Bbtn));
5536 sprintf(str_s,"%03d\n%s",Sbtn,joybtn_name(Sbtn));
5537 sprintf(str_l,"%03d\n%s",Lbtn,joybtn_name(Lbtn));
5538 sprintf(str_r,"%03d\n%s",Rbtn,joybtn_name(Rbtn));
5539 sprintf(str_m,"%03d\n%s",Mbtn,joybtn_name(Mbtn));
5540 sprintf(str_p,"%03d\n%s",Pbtn,joybtn_name(Pbtn));
5541 sprintf(str_ex1,"%03d\n%s",Exbtn1,joybtn_name(Exbtn1));
5542 sprintf(str_ex2,"%03d\n%s",Exbtn2,joybtn_name(Exbtn2));
5543 sprintf(str_ex3,"%03d\n%s",Exbtn3,joybtn_name(Exbtn3));
5544 sprintf(str_ex4,"%03d\n%s",Exbtn4,joybtn_name(Exbtn4));
5545 sprintf(str_up,"%03d\n%s",DUbtn,joybtn_name(DUbtn));
5546 sprintf(str_down,"%03d\n%s",DDbtn,joybtn_name(DDbtn));
5547 sprintf(str_left,"%03d\n%s",DLbtn,joybtn_name(DLbtn));
5548 sprintf(str_right,"%03d\n%s",DRbtn,joybtn_name(DRbtn));
5549 sprintf(str_primary_stick,"%03d\n%s",js_stick_1_x_stick,joystick_name(js_stick_1_x_stick));
5550 sprintf(str_secondary_stick,"%03d\n%s",js_stick_2_x_stick,joystick_name(js_stick_2_x_stick));
5551 sprintf(str_leftmod1,"%03d\n%s",cheat_modifier_keys[0],key_str[cheat_modifier_keys[0]]);
5552 sprintf(str_leftmod2,"%03d\n%s",cheat_modifier_keys[1],key_str[cheat_modifier_keys[1]]);
5553 sprintf(str_rightmod1,"%03d\n%s",cheat_modifier_keys[2],key_str[cheat_modifier_keys[2]]);
5554 sprintf(str_rightmod2,"%03d\n%s",cheat_modifier_keys[3],key_str[cheat_modifier_keys[3]]);
5555 break;
5556
5557 case 2:
5558 sprintf(str_a," %3d",midi_volume);
5559 sprintf(str_b," %3d",digi_volume);
5560 sprintf(str_l," %3d",emusic_volume);
5561 sprintf(str_m," %3dKB",zcmusic_bufsz);
5562 sprintf(str_r," %3d",sfx_volume);
5563 strcpy(str_s,pan_str[pan_style]);
5564 sprintf(str_leftmod1,"%3d\n%s",cheat_modifier_keys[0],key_str[cheat_modifier_keys[0]]);
5565 sprintf(str_leftmod2,"%3d\n%s",cheat_modifier_keys[1],key_str[cheat_modifier_keys[1]]);
5566 sprintf(str_rightmod1,"%3d\n%s",cheat_modifier_keys[2],key_str[cheat_modifier_keys[2]]);
5567 sprintf(str_rightmod2,"%3d\n%s",cheat_modifier_keys[3],key_str[cheat_modifier_keys[3]]);
5568 break;
5569 }
5570 }
5571
5572 return D_O_K;
5573 }
5574
5575 int32_t set_vol(void *dp3, int32_t d2)
5576 {
5577 switch(((int32_t*)dp3)[0])
5578 {
5579 case 0:
5580 midi_volume = zc_min(d2<<3,255);
5581 break;
5582
5583 case 1:
5584 digi_volume = zc_min(d2<<3,255);
5585 break;
5586
5587 case 2:
5588 emusic_volume = zc_min(d2<<3,255);
5589 break;
5590
5591 case 3:
5592 sfx_volume = zc_min(d2<<3,255);
5593 break;
5594 }
5595
5596 // text_mode(vc(11));
5597 textprintf_right_ex(screen,get_zc_font(font_lfont_l), ((int32_t*)dp3)[1],((int32_t*)dp3)[2],jwin_pal[jcBOXFG],jwin_pal[jcBOX],"%3d",zc_min(d2<<3,255));
5598 return D_O_K;
5599 }
5600
5601 int32_t set_pan(void *dp3, int32_t d2)
5602 {
5603 pan_style = vbound(d2,0,3);
5604 // text_mode(vc(11));
5605 textout_right_ex(screen,get_zc_font(font_lfont_l), pan_str[pan_style],((int32_t*)dp3)[1],((int32_t*)dp3)[2],jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5606 return D_O_K;
5607 }
5608
5609 int32_t set_buf(void *dp3, int32_t d2)
5610 {
5611 // text_mode(vc(11));
5612 zcmusic_bufsz = d2 + 1;
5613 textprintf_right_ex(screen,get_zc_font(font_lfont_l), ((int32_t*)dp3)[1],((int32_t*)dp3)[2],jwin_pal[jcBOXFG],jwin_pal[jcBOX],"%3dKB",zcmusic_bufsz);
5614 return D_O_K;
5615 }
5616
5617 static int32_t gamepad_joys_list[] =
5618 {
5619 61,
5620 -1
5621 };
5622
5623 static int32_t gamepad_btn_list[] =
5624 {
5625 6,
5626 7,8,9,10,11,12,13,14,15,16,17,
5627 18,19,20,21,22,23,24,25,26,27,28,
5628 29,30,31,32,33,34,35,36,37,38,39,
5629 -1
5630 };
5631
5632 static int32_t gamepad_dirs_list[] =
5633 {
5634 40,41,42,43,
5635 44,45,46,47,
5636 48,49,50,51,
5637 52,53,54,55,
5638 56,57,58,59,
5639 60,
5640 -1
5641 };
5642
5643 static TABPANEL gamepad_tabs[] =
5644 {
5645 // (text)
5646 { (char *)"Controllers", D_SELECTED, gamepad_joys_list, 0, NULL },
5647 { (char *)"Buttons", 0, gamepad_btn_list, 0, NULL },
5648 { (char *)"Directions", 0, gamepad_dirs_list, 0, NULL },
5649 { NULL, 0, NULL, 0, NULL }
5650 };
5651
5652 const char *joy_list(int32_t index, int32_t *list_size)
5653 {
5654 if (index == -1)
5655 {
5656 *list_size = al_get_num_joysticks();
5657 return NULL;
5658 }
5659
5660 ALLEGRO_JOYSTICK* joy = al_get_joystick(index);
5661 if (!joy)
5662 {
5663 return "?";
5664 }
5665
5666 return al_get_joystick_name(joy);
5667 }
5668
5669 116 static ListData joy__list(joy_list, &font);
5670
5671 static int32_t d_joylist_proc(int32_t msg,DIALOG *d,int32_t c)
5672 {
5673 int32_t d2 = d->d2;
5674 int32_t ret = jwin_droplist_proc(msg,d,c);
5675
5676 if(d2!=d->d2)
5677 {
5678 joystick_index = d->d2;
5679 ret |= D_REDRAW_ALL;
5680 }
5681
5682 return ret;
5683 }
5684
5685 static DIALOG gamepad_dlg[] =
5686 {
5687 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3)
5688 { jwin_win_proc, 8, 24, 304, 256, 0, 0, 0, D_EXIT, 0, 0, (void *) "Gamepad Controls", NULL, NULL },
5689 { jwin_tab_proc, 8+4, 24+23,304-8,256-52,vc(0), vc(15), 0, 0, 0, 0, (void *) gamepad_tabs, NULL, (void *)gamepad_dlg },
5690 { d_stringloader, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5691 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5692 { jwin_button_proc, 90, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
5693 { jwin_button_proc, 170, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
5694 // 6
5695 { d_dummy_proc, 14, 61, 294, 192, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5696 // 7
5697 { jwin_ctext_proc, 92, 92-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_a, NULL, NULL },
5698 { jwin_ctext_proc, 92, 120-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_b, NULL, NULL },
5699 { jwin_ctext_proc, 92, 148-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
5700 { jwin_ctext_proc, 92, 180-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex1, NULL, NULL },
5701 { jwin_ctext_proc, 92, 212-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex3, NULL, NULL },
5702 { jwin_ctext_proc, 237, 92-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_l, NULL, NULL },
5703 { jwin_ctext_proc, 237, 120-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_r, NULL, NULL },
5704 { jwin_ctext_proc, 237, 148-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_p, NULL, NULL },
5705 { jwin_ctext_proc, 237, 180-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex2, NULL, NULL },
5706 { jwin_ctext_proc, 237, 212-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex4, NULL, NULL },
5707 { jwin_ctext_proc, 92, 244-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_m, NULL, NULL },
5708 // 18
5709 { d_jbutton_proc, 22, 90-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "A", NULL, &Abtn},
5710 { d_jbutton_proc, 22, 118-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "B", NULL, &Bbtn},
5711 { d_jbutton_proc, 22, 146-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Start", NULL, &Sbtn},
5712 { d_jbutton_proc, 22, 178-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "X (EX1)", NULL, &Exbtn1},
5713 { d_jbutton_proc, 22, 210-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX3", NULL, &Exbtn3},
5714 { d_jbutton_proc, 167, 90-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "L", NULL, &Lbtn},
5715 { d_jbutton_proc, 167, 118-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "R", NULL, &Rbtn},
5716 { d_jbutton_proc, 167, 146-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Map", NULL, &Pbtn},
5717 { d_jbutton_proc, 167, 178-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Y (EX2)", NULL, &Exbtn2},
5718 { d_jbutton_proc, 167, 210-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX4", NULL, &Exbtn4},
5719 { d_jbutton_proc, 22, 242-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Menu", NULL, &Mbtn},
5720 // 29
5721 { d_j_clearbutton_proc, 22+91, 90-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Abtn},
5722 { d_j_clearbutton_proc, 22+91, 118-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Bbtn},
5723 { d_j_clearbutton_proc, 22+91, 146-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Sbtn},
5724 { d_j_clearbutton_proc, 22+91, 178-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn1},
5725 { d_j_clearbutton_proc, 22+91, 210-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn3},
5726 { d_j_clearbutton_proc, 167+91, 90-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Lbtn},
5727 { d_j_clearbutton_proc, 167+91, 118-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Rbtn},
5728 { d_j_clearbutton_proc, 167+91, 146-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Pbtn},
5729 { d_j_clearbutton_proc, 167+91, 178-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn2},
5730 { d_j_clearbutton_proc, 167+91, 210-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn4},
5731 { d_j_clearbutton_proc, 22+91, 242-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Mbtn},
5732 // 40
5733 { jwin_frame_proc, 14, 62, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5734 { jwin_frame_proc, 159, 62, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5735 { jwin_text_proc, 30, 68, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Vertical", NULL, NULL },
5736 { jwin_text_proc, 175, 68, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Horizontal", NULL, NULL },
5737 // 44
5738 { jwin_text_proc, 92, 84, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_up, NULL, NULL },
5739 { jwin_text_proc, 92, 112, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_down, NULL, NULL },
5740 { jwin_text_proc, 237, 84, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_left, NULL, NULL },
5741 { jwin_text_proc, 237, 112, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_right, NULL, NULL },
5742 // 48
5743 { d_jbutton_proc, 22, 82, 61, 21, vc(14), vc(11), 0, 0, 0, 0, (void *) "Up", NULL, &DUbtn },
5744 { d_jbutton_proc, 22, 110, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Down", NULL, &DDbtn },
5745 { d_jbutton_proc, 167, 82, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Left", NULL, &DLbtn },
5746 { d_jbutton_proc, 167, 110, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Right", NULL, &DRbtn },
5747 // 52
5748 { d_j_clearbutton_proc, 22+91, 82, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DUbtn},
5749 { d_j_clearbutton_proc, 22+91, 110, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DDbtn},
5750 { d_j_clearbutton_proc, 167+91, 82, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DLbtn},
5751 { d_j_clearbutton_proc, 167+91, 110, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DRbtn},
5752 // 56
5753 { jwin_check_proc, 22, 150, 147, 8, vc(14), vc(1), 0, 0, 1, 0, (void *) "Primary: Use Analog Stick (Ignore above and use below instead)", NULL, NULL },
5754 { d_jstick_proc, 22, 165, 61, 21, vc(14), vc(11), 0, 0, 0, 0, (void *) "Primary", NULL, &js_stick_1_x_stick },
5755 { d_jstick_proc, 22, 195, 61, 21, vc(14), vc(11), 0, 0, 0, 0, (void *) "Secondary", NULL, &js_stick_2_x_stick },
5756 { jwin_text_proc, 90, 165, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_primary_stick, NULL, NULL },
5757 { jwin_text_proc, 90, 195, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_secondary_stick, NULL, NULL },
5758
5759 // 61
5760 { d_joylist_proc, 22, 62, 150, 16, 0, 0, 0, 0, 0, 0, (void *) &joy__list, NULL, NULL },
5761
5762 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5763 };
5764
5765 static int32_t keyboard_keys_list[] =
5766 {
5767 6,7,8,9,10,
5768 11,12,13,14,15,16,17,18,19,20,
5769 21,22,23,24,25,26,27,28,29,30,
5770 31,32,33,34,35,36,37,38,39,40,
5771 -1
5772 };
5773
5774 static int32_t keyboard_dirs_list[] =
5775 {
5776 41,42,43,44,
5777 45,46,47,48,
5778 49,50,51,52,
5779 53,54,55,56,
5780 -1
5781 };
5782
5783 static int32_t keyboard_mods_list[] =
5784 {
5785 57,58,59,60,
5786 61,62,63,64,
5787 65,66,67,68,
5788 69,70,71,72,
5789 -1
5790 };
5791
5792 static TABPANEL keyboard_control_tabs[] =
5793 {
5794 // (text)
5795 { (char *)"Keys", D_SELECTED, keyboard_keys_list, 0, NULL },
5796 { (char *)"Directions", 0, keyboard_dirs_list, 0, NULL },
5797 { (char *)"Cheat Mods", 0, keyboard_mods_list, 0, NULL },
5798 { NULL, 0, NULL, 0, NULL }
5799 };
5800
5801 static DIALOG keyboard_control_dlg[] =
5802 {
5803 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3)
5804 { jwin_win_proc, 8, 39, 304, 240, 0, 0, 0, D_EXIT, 0, 0, (void *) "Keyboard Controls", NULL, NULL },
5805 { jwin_tab_proc, 8+4, 39+23,304-8,240-56,vc(0), vc(15), 0, 0, 0, 0, (void *) keyboard_control_tabs, NULL, (void *)keyboard_control_dlg },
5806 { d_stringloader, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5807 { jwin_button_proc, 90, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
5808 { jwin_button_proc, 170, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
5809 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5810 // Keys
5811 // 6
5812 { jwin_frame_proc, 14, 80, 148, 105, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5813 { jwin_frame_proc, 158, 80, 148, 105, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5814 { jwin_frame_proc, 14, 181, 292, 67, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5815 { jwin_text_proc, 30, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Standard", NULL, NULL },
5816 { jwin_text_proc, 175, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Extended", NULL, NULL },
5817 // 11
5818 { jwin_text_proc, 92-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_a, NULL, NULL },
5819 { jwin_text_proc, 92-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_b, NULL, NULL },
5820 { jwin_text_proc, 92-4, 158, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
5821 { jwin_text_proc, 92-4, 190, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex1, NULL, NULL },
5822 { jwin_text_proc, 92-4, 222, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex3, NULL, NULL },
5823 { jwin_text_proc, 237-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_l, NULL, NULL },
5824 { jwin_text_proc, 237-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_r, NULL, NULL },
5825 { jwin_text_proc, 237-4, 158, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_p, NULL, NULL },
5826 { jwin_text_proc, 237-4, 190, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex2, NULL, NULL },
5827 { jwin_text_proc, 237-4, 222, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex4, NULL, NULL },
5828 // 21
5829 { d_kbutton_proc, 22, 100, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "A", NULL, &Akey},
5830 { d_kbutton_proc, 22, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "B", NULL, &Bkey},
5831 { d_kbutton_proc, 22, 156, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Start", NULL, &Skey},
5832 { d_kbutton_proc, 22, 188, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "X (EX1)", NULL, &Exkey1},
5833 { d_kbutton_proc, 22, 220, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX3", NULL, &Exkey3},
5834 { d_kbutton_proc, 167, 100, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "L", NULL, &Lkey},
5835 { d_kbutton_proc, 167, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "R", NULL, &Rkey},
5836 { d_kbutton_proc, 167, 156, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Map", NULL, &Pkey},
5837 { d_kbutton_proc, 167, 188, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Y (EX2)", NULL, &Exkey2},
5838 { d_kbutton_proc, 167, 220, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX4", NULL, &Exkey4},
5839 // 31
5840 { d_k_clearbutton_proc, 22+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Akey},
5841 { d_k_clearbutton_proc, 22+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Bkey},
5842 { d_k_clearbutton_proc, 22+91, 156, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Skey},
5843 { d_k_clearbutton_proc, 22+91, 188, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey1},
5844 { d_k_clearbutton_proc, 22+91, 220, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey3},
5845 { d_k_clearbutton_proc, 167+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Lkey},
5846 { d_k_clearbutton_proc, 167+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Rkey},
5847 { d_k_clearbutton_proc, 167+91, 156, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Pkey},
5848 { d_k_clearbutton_proc, 167+91, 188, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey2},
5849 { d_k_clearbutton_proc, 167+91, 220, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey4},
5850 // Dirs
5851 // 41
5852 { jwin_frame_proc, 14, 80, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5853 { jwin_frame_proc, 159, 80, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5854 { jwin_text_proc, 30, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Vertical", NULL, NULL },
5855 { jwin_text_proc, 175, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Horizontal", NULL, NULL },
5856 // 45
5857 { jwin_text_proc, 92-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_up, NULL, NULL },
5858 { jwin_text_proc, 92-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_down, NULL, NULL },
5859 { jwin_text_proc, 237-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_left, NULL, NULL },
5860 { jwin_text_proc, 237-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_right, NULL, NULL },
5861 // 49
5862 { d_kbutton_proc, 22, 100, 61, 21, vc(14), vc(11), 0, 0, 0, 0, (void *) "Up", NULL, &DUkey},
5863 { d_kbutton_proc, 22, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Down", NULL, &DDkey},
5864 { d_kbutton_proc, 167, 100, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Left", NULL, &DLkey},
5865 { d_kbutton_proc, 167, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Right", NULL, &DRkey},
5866 // 53
5867 { d_k_clearbutton_proc, 22+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DUkey},
5868 { d_k_clearbutton_proc, 22+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DDkey},
5869 { d_k_clearbutton_proc, 167+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DLkey},
5870 { d_k_clearbutton_proc, 167+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DRkey},
5871 // Mods
5872 // 57
5873 { jwin_frame_proc, 14, 80, 148, 140-58, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5874 { jwin_frame_proc, 158, 80, 148, 140-58, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5875 { jwin_text_proc, 30, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Left", NULL, NULL },
5876 { jwin_text_proc, 175, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Right", NULL, NULL },
5877 // 61
5878 { jwin_text_proc, 92-26, 101, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_leftmod1, NULL, NULL },
5879 { jwin_text_proc, 92-26, 129, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_rightmod1, NULL, NULL },
5880 { jwin_text_proc, 237-4-22,101, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_leftmod2, NULL, NULL },
5881 { jwin_text_proc, 237-4-22,129, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_rightmod2, NULL, NULL },
5882 // 65
5883 { d_kbutton_proc, 22, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Main", NULL, &cheat_modifier_keys[0]},
5884 { d_kbutton_proc, 22, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Second", NULL, &cheat_modifier_keys[2]},
5885 { d_kbutton_proc, 167, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Main", NULL, &cheat_modifier_keys[1]},
5886 { d_kbutton_proc, 167, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Second", NULL, &cheat_modifier_keys[3]},
5887 // 69
5888 { d_k_clearbutton_proc, 22+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[0]},
5889 { d_k_clearbutton_proc, 22+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[2]},
5890 { d_k_clearbutton_proc, 167+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[1]},
5891 { d_k_clearbutton_proc, 167+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[3]},
5892 // 73
5893 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5894 };
5895
5896 /*
5897 int32_t midi_dp[3] = {0,147,104};
5898 int32_t digi_dp[3] = {1,147,120};
5899 int32_t pan_dp[3] = {0,147,136};
5900 int32_t buf_dp[3] = {0,147,152};
5901 */
5902 int32_t midi_dp[3] = {0,0,0};
5903 int32_t digi_dp[3] = {1,0,0};
5904 int32_t emus_dp[3] = {2,0,0};
5905 int32_t buf_dp[3] = {0,0,0};
5906 int32_t sfx_dp[3] = {3,0,0};
5907 int32_t pan_dp[3] = {0,0,0};
5908
5909 static DIALOG sound_dlg[] =
5910 {
5911 //(dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3)
5912 116 { jwin_win_proc, 0, 0, 320, 178, 0, 0, 0, D_EXIT, 0, 0, (void *) "Sound Settings", NULL, NULL },
5913 116 { d_stringloader, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5914 116 { jwin_button_proc, 58, 148, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
5915 116 { jwin_button_proc, 138, 148, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
5916 116 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5917 116 { jwin_frame_proc, 10, 28, 300, 112, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
5918 116 { jwin_rtext_proc, 190, 40, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_a, NULL, NULL },
5919 116 { jwin_rtext_proc, 190, 56, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_b, NULL, NULL },
5920 116 { jwin_rtext_proc, 190, 72, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_l, NULL, NULL },
5921 116 { jwin_rtext_proc, 190, 88, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_m, NULL, NULL },
5922 // 10
5923 116 { jwin_rtext_proc, 190, 104, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_r, NULL, NULL },
5924 116 { jwin_rtext_proc, 190, 120, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_s, NULL, NULL },
5925 116 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5926 116 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5927 116 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5928 116 { jwin_slider_proc, 196, 40, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, midi_dp },
5929 116 { jwin_slider_proc, 196, 56, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, digi_dp },
5930 116 { jwin_slider_proc, 196, 72, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, emus_dp },
5931 116 { jwin_slider_proc, 196, 88, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 127, 0, NULL, (void *) set_buf, buf_dp },
5932 116 { jwin_slider_proc, 196, 104, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, sfx_dp },
5933 //20
5934 116 { jwin_slider_proc, 196, 120, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 3, 0, NULL, (void *) set_pan, pan_dp },
5935 116 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5936 116 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5937 116 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5938 116 { jwin_text_proc, 17, 40, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Master MIDI Volume", NULL, NULL },
5939 116 { jwin_text_proc, 17, 56, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Master Digi Volume", NULL, NULL },
5940 116 { jwin_text_proc, 17, 72, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Enhanced Music Volume", NULL, NULL },
5941 116 { jwin_text_proc, 17, 88, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Enhanced Music Buffer", NULL, NULL },
5942 116 { jwin_text_proc, 17, 104, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "SFX Volume", NULL, NULL },
5943 116 { jwin_text_proc, 17, 120, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "SFX Pan", NULL, NULL },
5944 //30
5945 116 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5946 116 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5947 116 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5948 116 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5949 };
5950
5951 char zc_builddate[80];
5952 char zc_aboutstr[80];
5953
5954 static DIALOG about_dlg[] =
5955 {
5956 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
5957 { jwin_win_proc, 68, 52, 184, 154, 0, 0, 0, D_EXIT, 0, 0, (void *) "About", NULL, NULL },
5958 { jwin_button_proc, 140, 176, 41, 21, vc(14), 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
5959 { jwin_ctext_proc, 160, 84, 0, 8, vc(0), vc(11), 0, 0, 0, 0, zc_aboutstr, NULL, NULL },
5960 { jwin_ctext_proc, 160, 92, 0, 8, vc(0) , vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
5961 { jwin_ctext_proc, 160, 100, 0, 8, vc(0) , vc(11), 0, 0, 0, 0, zc_builddate, NULL, NULL },
5962 { jwin_text_proc, 88, 124, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Coded by:", NULL, NULL },
5963 { jwin_text_proc, 88, 132, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) " Phantom Menace", NULL, NULL },
5964 { jwin_text_proc, 88, 144, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Produced by:", NULL, NULL },
5965 { jwin_text_proc, 88, 152, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) " Armageddon Games", NULL, NULL },
5966 { jwin_frame_proc, 80, 117, 160, 50, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5967 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5968 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5969 };
5970
5971
5972 static DIALOG quest_dlg[] =
5973 {
5974 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
5975 { jwin_win_proc, 68, 25, 184, 190, 0, 0, 0, D_EXIT, 0, 0, (void *) "Quest Info", NULL, NULL },
5976 { jwin_edit_proc, 84, 54, 152, 16, 0, 0, 0, D_READONLY, 100, 0, NULL, NULL, NULL },
5977 { jwin_text_proc, 89, 84, 141, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Number:", NULL, NULL },
5978 { jwin_text_proc, 152, 84, 24, 8, vc(7), vc(11), 0, 0, 0, 0, str_a, NULL, NULL },
5979 { jwin_text_proc, 89, 94, 141, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Version:", NULL, NULL },
5980 { jwin_text_proc, 160, 94, 64, 8, vc(7), vc(11), 0, 0, 0, 0, header_version_nul_term, NULL, NULL },
5981 { jwin_text_proc, 89, 104, 141, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "ZQ Version:", NULL, NULL },
5982 { jwin_text_proc, 184, 104, 64, 8, vc(7), vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
5983 { jwin_text_proc, 84, 126, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Title:", NULL, NULL },
5984 { jwin_textbox_proc, 84, 136, 152, 24, 0, 0, 0, 0, 0, 0, QHeader.title, NULL, NULL },
5985 { jwin_text_proc, 84, 168, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Author:", NULL, NULL },
5986 { jwin_textbox_proc, 84, 178, 152, 24, 0, 0, 0, 0, 0, 0, QHeader.author, NULL, NULL },
5987 { jwin_frame_proc, 84, 79, 152, 38, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5988 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5989 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5990 };
5991
5992 static DIALOG triforce_dlg[] =
5993 {
5994 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
5995 { jwin_win_proc, 72, 64, 177, 105, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Triforce Pieces", NULL, NULL },
5996 // 1
5997 { jwin_check_proc, 129, 94, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "1", NULL, NULL },
5998 { jwin_check_proc, 129, 104, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "2", NULL, NULL },
5999 { jwin_check_proc, 129, 114, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "3", NULL, NULL },
6000 { jwin_check_proc, 129, 124, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "4", NULL, NULL },
6001 { jwin_check_proc, 172, 94, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "5", NULL, NULL },
6002 { jwin_check_proc, 172, 104, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "6", NULL, NULL },
6003 { jwin_check_proc, 172, 114, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "7", NULL, NULL },
6004 { jwin_check_proc, 172, 124, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "8", NULL, NULL },
6005 // 9
6006 { jwin_button_proc, 90, 144, 61, 21, vc(0), vc(11), 'k', D_EXIT, 0, 0, (void *) "O&K", NULL, NULL },
6007 { jwin_button_proc, 170, 144, 61, 21, vc(0), vc(11), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
6008 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6009 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6010 };
6011
6012 bool zc_getname(const char *prompt,const char *ext,EXT_LIST *list,const char *def,bool usefilename)
6013 {
6014 go();
6015 int32_t ret=0;
6016 ret = zc_getname_nogo(prompt,ext,list,def,usefilename);
6017 comeback();
6018 return ret != 0;
6019 }
6020
6021
6022 bool zc_getname_nogo(const char *prompt,const char *ext,EXT_LIST *list,const char *def,bool usefilename)
6023 {
6024 if(def!=modulepath)
6025 strcpy(modulepath,def);
6026
6027 if(!usefilename)
6028 {
6029 int32_t i=(int32_t)strlen(modulepath);
6030
6031 while(i>=0 && modulepath[i]!='\\' && modulepath[i]!='/')
6032 modulepath[i--]=0;
6033 }
6034
6035 // int32_t ret = file_select_ex(prompt,modulepath,ext,255,-1,-1);
6036 int32_t ret=0;
6037 int32_t sel=0;
6038
6039 if(list==NULL)
6040 {
6041 ret = jwin_file_select_ex(prompt,modulepath,ext,2048,-1,-1,get_zc_font(font_lfont));
6042 }
6043 else
6044 {
6045 ret = jwin_file_browse_ex(prompt, modulepath, list, &sel, 2048, -1, -1, get_zc_font(font_lfont));
6046 }
6047
6048 return ret!=0;
6049 }
6050
6051 int32_t onToggleRecordingNewSaves()
6052 {
6053 if (zc_get_config("zeldadx", "replay_new_saves", false))
6054 {
6055 zc_set_config("zeldadx", "replay_new_saves", false);
6056 }
6057 else
6058 {
6059 zc_set_config("zeldadx", "replay_new_saves", true);
6060 jwin_alert("Recording", "Newly created saves will be recorded and written to a replay file.",
6061 NULL,NULL,"OK",NULL,13,27,get_zc_font(font_lfont));
6062 }
6063 return D_O_K;
6064 }
6065
6066 int32_t onToggleSnapshotAllFrames()
6067 {
6068 replay_set_snapshot_all_frames(!replay_is_snapshot_all_frames());
6069 return D_O_K;
6070 }
6071
6072 int32_t onStopReplayOrRecord()
6073 {
6074 if (replay_is_replaying())
6075 {
6076 replay_quit();
6077 }
6078 else if (replay_get_mode() == ReplayMode::Record)
6079 {
6080 if (!replay_get_meta_bool("test_mode"))
6081 {
6082 jwin_alert("Recording", "You cannot stop recording a save file.",
6083 NULL,NULL,"OK",NULL,13,27,get_zc_font(font_lfont));
6084 return D_CLOSE;
6085 }
6086
6087 if (jwin_alert("Stop Recording",
6088 "Save replay to disk and stop recording?",
6089 "This will stop the recording.",
6090 NULL,
6091 "Yes","No",13,27,get_zc_font(font_lfont)) != 1)
6092 return D_CLOSE;
6093
6094 replay_save();
6095 replay_stop();
6096 }
6097 return D_O_K;
6098 }
6099
6100 static int32_t handle_on_load_replay(ReplayMode mode)
6101 {
6102 if (Playing)
6103 {
6104 if (jwin_alert("Replay - Warning!",
6105 "Loading a replay will exit the current game.",
6106 "All unsaved progress will be lost.",
6107 "Do you wish to continue?",
6108 "Yes","No",13,27,get_zc_font(font_lfont)) != 1)
6109 return D_CLOSE;
6110 }
6111
6112 std::string mode_string = replay_mode_to_string(mode);
6113 mode_string[0] = std::toupper(mode_string[0]);
6114
6115 std::string line_1 = "Select a replay file to play back.";
6116 std::string line_2 = "You won't be able to save, and it won't effect existing saves.";
6117 std::string line_3 = "You can stop the replay and take over manually any time.";
6118 if (mode == ReplayMode::Update)
6119 {
6120 line_1 = "Select a replay file to update.";
6121 line_2 = "WARNING: be sure to back up the zplay file";
6122 line_3 = "and verify that the updated replay works as expected!";
6123 }
6124
6125 if (jwin_alert(mode_string.c_str(),
6126 line_1.c_str(),
6127 line_2.c_str(),
6128 line_3.c_str(),
6129 "OK","Nevermind",13,27,get_zc_font(font_lfont)) == 1)
6130 {
6131 char replay_path[2048];
6132 strcpy(replay_path, "replays/");
6133 if (jwin_file_select_ex(
6134 fmt::format("Load Replay ({})", REPLAY_EXTENSION).c_str(),
6135 replay_path, REPLAY_EXTENSION.c_str(), 2048, -1, -1, get_zc_font(font_lfont)) == 0)
6136 return D_CLOSE;
6137
6138 replay_quit();
6139 load_replay_file_deferred(mode, replay_path);
6140 Quit = qRESET;
6141 return D_CLOSE;
6142 }
6143 return D_O_K;
6144 }
6145
6146 int32_t onLoadReplay()
6147 {
6148 return handle_on_load_replay(ReplayMode::Replay);
6149 }
6150
6151 int32_t onLoadReplayAssert()
6152 {
6153 return handle_on_load_replay(ReplayMode::Assert);
6154 }
6155
6156 int32_t onLoadReplayUpdate()
6157 {
6158 return handle_on_load_replay(ReplayMode::Update);
6159 }
6160
6161 int32_t onSaveReplay()
6162 {
6163 if (replay_get_mode() == ReplayMode::Record)
6164 {
6165 if (!replay_get_meta_bool("test_mode"))
6166 {
6167 if (jwin_alert("Save Replay",
6168 "This will save a copy of the replay up to this point.",
6169 "The official replay file will be untouched.",
6170 "Do you wish to continue?",
6171 "Yes","No",13,27,get_zc_font(font_lfont)) != 1)
6172 return D_CLOSE;
6173
6174 char replay_path[2048];
6175 strcpy(replay_path, replay_get_replay_path().string().c_str());
6176 if (jwin_file_select_ex(
6177 fmt::format("Save Replay ({})", REPLAY_EXTENSION).c_str(),
6178 replay_path, REPLAY_EXTENSION.c_str(), 2048, -1, -1, get_zc_font(font_lfont)) == 0)
6179 return D_CLOSE;
6180
6181 if (fileexists(replay_path))
6182 {
6183 jwin_alert("Save Replay", "You cannot overwrite an existing file.",
6184 NULL,NULL,"OK",NULL,13,27,get_zc_font(font_lfont));
6185 return D_CLOSE;
6186 }
6187
6188 replay_save(replay_path);
6189 }
6190 else
6191 {
6192 replay_save();
6193 }
6194 }
6195 return D_O_K;
6196 }
6197
6198 static MENU replay_menu[] =
6199 {
6200 { (char *)"Record new saves", onToggleRecordingNewSaves, NULL, 0, NULL },
6201 { (char *)"Stop replay", onStopReplayOrRecord, NULL, 0, NULL },
6202 { (char *)"Load replay", onLoadReplay, NULL, 0, NULL },
6203 { (char *)"Load replay (assert)", onLoadReplayAssert, NULL, 0, NULL },
6204 { (char *)"Load replay (update)", onLoadReplayUpdate, NULL, 0, NULL },
6205 { (char *)"Save replay", onSaveReplay, NULL, 0, NULL },
6206 { (char *)"Enable snapshot all frames", onToggleSnapshotAllFrames,NULL, 0, NULL },
6207
6208 { NULL, NULL, NULL, 0, NULL }
6209 };
6210
6211 static DIALOG credits_dlg[] =
6212 {
6213 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
6214 { jwin_win_proc, 40, 38, 241, 173, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "ZQuest Classic Credits", NULL, NULL },
6215 { jwin_frame_proc, 47, 65, 227, 115, vc(15), vc(1), 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
6216 { d_bitmap_proc, 49, 67, 222, 110, vc(15), vc(1), 0, 0, 0, 0, NULL, NULL, NULL },
6217 { jwin_button_proc, 140, 184, 41, 21, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
6218 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6219 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6220 };
6221
6222 116 static ListData dmap_list(dmaplist, &font);
6223
6224 static DIALOG goto_dlg[] =
6225 {
6226 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
6227 { jwin_win_proc, 48, 25, 205, 100, 0, 0, 0, D_EXIT, 0, 0, (void *) "Goto Location", NULL, NULL },
6228 { jwin_button_proc, 90, 176-78, 61, 21, vc(14), 0, 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
6229 { jwin_button_proc, 170, 176-78, 61, 21, vc(14), 0, 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
6230 { jwin_text_proc, 55, 129-75, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "DMap:", NULL, NULL },
6231 { jwin_droplist_proc, 88, 126-75, 160, 16, 0, 0, 0, 0, 0, 0, (void *) &dmap_list, NULL, NULL },
6232 { jwin_text_proc, 55, 149-75, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Screen:", NULL, NULL },
6233 { jwin_edit_proc, 132, 146-75, 91, 16, 0, 0, 0, 0, 2, 0, NULL, NULL, NULL },
6234 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6235 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6236 };
6237
6238 int32_t onGoTo()
6239 {
6240 bool music = false;
6241 music = music;
6242 sprintf(cheat_goto_screen_str,"%X",cheat_goto_screen);
6243
6244 goto_dlg[0].dp2=get_zc_font(font_lfont);
6245 goto_dlg[4].d2=cheat_goto_dmap;
6246 goto_dlg[6].dp=cheat_goto_screen_str;
6247
6248 clear_keybuf();
6249
6250 large_dialog(goto_dlg);
6251
6252 if(do_zqdialog(goto_dlg,4)==1)
6253 {
6254 // dmap, screen
6255 cheats_enqueue(Cheat::GoTo, goto_dlg[4].d2, zc_min(zc_xtoi(cheat_goto_screen_str),0x7F));
6256 };
6257
6258 return D_O_K;
6259 }
6260
6261 int32_t onGoToComplete()
6262 {
6263 if(!Playing)
6264 {
6265 return D_O_K;
6266 }
6267
6268 enter_sys_pal();
6269 music_pause();
6270 pause_all_sfx();
6271 onGoTo();
6272 eat_buttons();
6273
6274 zc_readrawkey(KEY_ESC);
6275
6276 exit_sys_pal();
6277 music_resume();
6278 resume_all_sfx();
6279 return D_O_K;
6280 }
6281
6282 int32_t onCredits()
6283 {
6284 return D_O_K;
6285 }
6286
6287 const char *midilist(int32_t index, int32_t *list_size)
6288 {
6289 if(index<0)
6290 {
6291 *list_size=0;
6292
6293 for(int32_t i=0; i<MAXMIDIS; i++)
6294 if(tunes[i].data)
6295 ++(*list_size);
6296
6297 return NULL;
6298 }
6299
6300 int32_t i=0,m=0;
6301
6302 while(m<=index && i<=MAXMIDIS)
6303 {
6304 if(tunes[i].data)
6305 ++m;
6306
6307 ++i;
6308 }
6309
6310 --i;
6311
6312 if(i==MAXMIDIS && m<index)
6313 return "(null)";
6314
6315 return tunes[i].title;
6316 }
6317
6318 /* ------- MIDI info stuff -------- */
6319
6320 char *text;
6321 midi_info *zmi;
6322 bool dialog_running;
6323 bool listening;
6324
6325 void get_info(int32_t index);
6326
6327 int32_t d_midilist_proc(int32_t msg,DIALOG *d,int32_t c)
6328 {
6329 int32_t d2 = d->d2;
6330 int32_t ret = jwin_droplist_proc(msg,d,c);
6331
6332 if(d2!=d->d2)
6333 {
6334 get_info(d->d2);
6335 }
6336
6337 return ret;
6338 }
6339
6340 int32_t d_listen_proc(int32_t msg,DIALOG *d,int32_t c)
6341 {
6342 /* 'd->d1' is offset from 'd' in DIALOG array to midilist proc */
6343
6344 int32_t ret = jwin_button_proc(msg,d,c);
6345
6346 if(ret == D_CLOSE)
6347 {
6348 // get current midi index
6349 int32_t index = (d+(d->d1))->d2;
6350 int32_t i=0, m=0;
6351
6352 while(m<=index && i<=MAXMIDIS)
6353 {
6354 if(tunes[i].data)
6355 ++m;
6356
6357 ++i;
6358 }
6359
6360 --i;
6361 jukebox(i);
6362 listening = true;
6363 ret = D_O_K;
6364 }
6365
6366 return ret;
6367 }
6368
6369 int32_t d_savemidi_proc(int32_t msg,DIALOG *d,int32_t c)
6370 {
6371 /* 'd->d1' is offset from 'd' in DIALOG array to midilist proc */
6372
6373 int32_t ret = jwin_button_proc(msg,d,c);
6374
6375 if(ret == D_CLOSE)
6376 {
6377 // get current midi index
6378 int32_t index = (d+(d->d1))->d2;
6379 int32_t i=0, m=0;
6380
6381 while(m<=index && i<=MAXMIDIS)
6382 {
6383 if(tunes[i].data)
6384 ++m;
6385
6386 ++i;
6387 }
6388
6389 --i;
6390
6391 // get file name
6392
6393 int32_t sel=0;
6394 //struct ffblk f;
6395 char title[40] = "Save MIDI: ";
6396 char fname[2048];
6397 memset(fname,0,2048);
6398 static EXT_LIST list[] =
6399 {
6400 { (char *)"MIDI files (*.mid)", (char *)"mid" },
6401 { (char *)"HTML files (*.html, *.html)", (char *)"htm html" },
6402 { NULL, NULL }
6403 };
6404
6405 strcpy(title+11, tunes[i].title);
6406 title[39] = '\0';
6407
6408 if(jwin_file_browse_ex(title, fname, list, &sel, 2048, -1, -1, get_zc_font(font_lfont))==0)
6409 goto done;
6410
6411 if(exists(fname))
6412 {
6413 if(jwin_alert(title, fname, "already exists.", "Overwrite it?", "&Yes","&No",'y','n',get_zc_font(font_lfont))==2)
6414 goto done;
6415 }
6416
6417 // save midi i
6418
6419 if(save_midi(fname, (MIDI*)tunes[i].data) != 0)
6420 jwin_alert(title, "Error saving MIDI to", fname, NULL, "Darn", NULL,13,27,get_zc_font(font_lfont));
6421
6422 done:
6423 chop_path(fname);
6424 ret = D_REDRAW;
6425 }
6426
6427 return ret;
6428 }
6429
6430 116 static ListData midi_list(midilist, &font);
6431
6432 static DIALOG midi_dlg[] =
6433 {
6434 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
6435 { jwin_win_proc, 8, 28, 304, 184, 0, 0, 0, D_EXIT, 0, 0, (void *) "MIDI Info", NULL, NULL },
6436 { jwin_text_proc, 32, 60, 40, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Tune:", NULL, NULL },
6437 { d_midilist_proc, 80, 56, 192, 16, 0, 0, 0, 0, 0, 0, (void *) &midi_list, NULL, NULL },
6438 { jwin_textbox_proc, 15, 80, 290, 96, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6439 { d_listen_proc, 24, 183, 72, 21, 0, 0, 'l', D_EXIT, -2, 0, (void *) "&Listen", NULL, NULL },
6440 { d_savemidi_proc, 108, 183, 72, 21, 0, 0, 's', D_EXIT, -3, 0, (void *) "&Save", NULL, NULL },
6441 { jwin_button_proc, 236, 183, 61, 21, 0, 0, 'k', D_EXIT, 0, 0, (void *) "O&K", NULL, NULL },
6442 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6443 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6444 };
6445
6446 void get_info(int32_t index)
6447 {
6448 int32_t i=0, m=0;
6449
6450 while(m<=index && i<=MAXMIDIS)
6451 {
6452 if(tunes[i].data)
6453 ++m;
6454
6455 ++i;
6456 }
6457
6458 --i;
6459
6460 if(i==MAXMIDIS && m<index)
6461 strcpy(text,"(null)");
6462 else
6463 {
6464 get_midi_info((MIDI*)tunes[i].data,zmi);
6465 get_midi_text((MIDI*)tunes[i].data,zmi,text);
6466 }
6467
6468 midi_dlg[0].dp2=get_zc_font(font_lfont);
6469 midi_dlg[3].dp = text;
6470 midi_dlg[3].d1 = midi_dlg[3].d2 = 0;
6471 midi_dlg[5].flags = (tunes[i].flags&tfDISABLESAVE) ? D_DISABLED : D_EXIT;
6472
6473 if(dialog_running)
6474 {
6475 jwin_textbox_proc(MSG_DRAW,midi_dlg+3,0);
6476 d_savemidi_proc(MSG_DRAW,midi_dlg+5,0);
6477 }
6478 }
6479
6480 int32_t onMIDICredits()
6481 {
6482 text = (char*)malloc(4096);
6483 zmi = (midi_info*)malloc(sizeof(midi_info));
6484
6485 if(!text || !zmi)
6486 {
6487 jwin_alert(NULL,"Not enough memory",NULL,NULL,"OK",NULL,13,27,get_zc_font(font_lfont));
6488 return D_O_K;
6489 }
6490
6491 bool do_pause_midi = midi_pos >= 0 && currmidi;
6492 auto restore_midi = currmidi;
6493 if(do_pause_midi)
6494 {
6495 paused_midi_pos = midi_pos;
6496 stop_midi();
6497 midi_suspended = midissuspHALTED;
6498 }
6499
6500 midi_dlg[0].dp2=get_zc_font(font_lfont);
6501 midi_dlg[2].d1 = 0;
6502 midi_dlg[2].d2 = 0;
6503 midi_dlg[4].flags = D_EXIT;
6504 midi_dlg[5].flags = (tunes[midi_dlg[2].d1].flags&tfDISABLESAVE) ? D_DISABLED : D_EXIT;
6505
6506 listening = false;
6507 dialog_running=false;
6508 get_info(0);
6509
6510 dialog_running=true;
6511
6512 large_dialog(midi_dlg);
6513
6514 do_zqdialog(midi_dlg,0);
6515 dialog_running=false;
6516
6517 if(listening)
6518 music_stop();
6519
6520 if(do_pause_midi)
6521 {
6522 // TODO: this probably doesn't resume midis nicely when scrolling (or in some other inner-gameloop).
6523 midi_suspended = midissuspRESUME;
6524 currmidi = restore_midi;
6525 midi_pos = paused_midi_pos;
6526 }
6527
6528 if(text) free(text);
6529 if(zmi) free(zmi);
6530 return D_O_K;
6531 }
6532
6533 int32_t onAbout()
6534 {
6535 char buf1[80]={0};
6536 std::ostringstream oss;
6537 sprintf(buf1,"%s, Version: %s", ZC_PLAYER_NAME,ZC_PLAYER_V);
6538 oss << buf1 << '\n';
6539 sprintf(buf1, "%s", ALPHA_VER_STR);
6540 oss << buf1 << '\n';
6541 sprintf(buf1,"Build Date: %s %s, %d at @ %s %s", dayextension(BUILDTM_DAY).c_str(), (char*)months[BUILDTM_MONTH], BUILDTM_YEAR, __TIME__, __TIMEZONE__);
6542 oss << buf1 << '\n';
6543 sprintf(buf1, "Built By: %s", DEV_SIGNOFF);
6544 oss << buf1 << '\n';
6545 sprintf(buf1, "Tag: %s", getReleaseTag());
6546 oss << buf1 << '\n';
6547
6548 InfoDialog("About ZC", oss.str()).show();
6549 return D_O_K;
6550 }
6551
6552 int32_t onQuest()
6553 {
6554 char fname[100];
6555 strcpy(fname, get_filename(qstpath));
6556 quest_dlg[0].dp2=get_zc_font(font_lfont);
6557 quest_dlg[1].dp = fname;
6558
6559 if(QHeader.quest_number==0)
6560 sprintf(str_a,"Custom");
6561 else
6562 sprintf(str_a,"%d",QHeader.quest_number);
6563
6564 sprintf(str_s,"%s",VerStr(QHeader.zelda_version));
6565
6566 quest_dlg[11].d1 = quest_dlg[9].d1 = 0;
6567 quest_dlg[11].d2 = quest_dlg[9].d2 = 0;
6568
6569 large_dialog(quest_dlg);
6570
6571 do_zqdialog(quest_dlg, 0);
6572 return D_O_K;
6573 }
6574
6575 void call_vidmode_dlg();
6576 int32_t onVidMode()
6577 {
6578 call_vidmode_dlg();
6579 return D_O_K;
6580 }
6581
6582 #define addToHash(c,b,h) if(h->find(c ## key) == h->end()) \
6583 {(*h)[c ## key]=true;} else { if ( c ## key != 0 ) b = false;}
6584 //Added an extra statement, so that if the key is cleared to 0, the cleared
6585 //keybinding status need not be unique. -Z ( 1st April, 2019 )
6586
6587 void load_ukeys(int32_t* arr)
6588 {
6589 arr[ukey_a] = Akey;
6590 arr[ukey_b] = Bkey;
6591 arr[ukey_s] = Skey;
6592 arr[ukey_l] = Lkey;
6593 arr[ukey_r] = Rkey;
6594 arr[ukey_p] = Pkey;
6595 arr[ukey_ex1] = Exkey1;
6596 arr[ukey_ex2] = Exkey2;
6597 arr[ukey_ex3] = Exkey3;
6598 arr[ukey_ex4] = Exkey4;
6599 arr[ukey_du] = DUkey;
6600 arr[ukey_dd] = DDkey;
6601 arr[ukey_dl] = DLkey;
6602 arr[ukey_dr] = DRkey;
6603 arr[ukey_mod1a] = cheat_modifier_keys[0];
6604 arr[ukey_mod1b] = cheat_modifier_keys[1];
6605 arr[ukey_mod2a] = cheat_modifier_keys[2];
6606 arr[ukey_mod2b] = cheat_modifier_keys[3];
6607 };
6608
6609 static const char* ukey_names[] = {
6610 "A", "B", "Start", "L", "R", "Map",
6611 "Ex1", "Ex2", "Ex3", "Ex4", "Up", "Down",
6612 "Left", "Right", "Cheat Mod L1", "Cheat Mod L2",
6613 "Cheat Mod R1", "Cheat Mod R2",
6614 };
6615 std::string get_ukey_name(int32_t k)
6616 {
6617 if (k < num_ukey) return ukey_names[k];
6618 return "";
6619 }
6620
6621 int32_t onKeyboard()
6622 {
6623 int32_t a = Akey;
6624 int32_t b = Bkey;
6625 int32_t s = Skey;
6626 int32_t l = Lkey;
6627 int32_t r = Rkey;
6628 int32_t p = Pkey;
6629 int32_t ex1 = Exkey1;
6630 int32_t ex2 = Exkey2;
6631 int32_t ex3 = Exkey3;
6632 int32_t ex4 = Exkey4;
6633 int32_t du = DUkey;
6634 int32_t dd = DDkey;
6635 int32_t dl = DLkey;
6636 int32_t dr = DRkey;
6637 int32_t mod1a = cheat_modifier_keys[0];
6638 int32_t mod1b = cheat_modifier_keys[1];
6639 int32_t mod2a = cheat_modifier_keys[2];
6640 int32_t mod2b = cheat_modifier_keys[3];
6641 bool done=false;
6642 int32_t ret;
6643
6644 keyboard_control_dlg[0].dp2=get_zc_font(font_lfont);
6645
6646 large_dialog(keyboard_control_dlg);
6647
6648 while(!done)
6649 {
6650 ret = do_zqdialog(keyboard_control_dlg,3);
6651
6652 if(ret==3) // OK
6653 {
6654 int32_t ukeys[num_ukey];
6655 load_ukeys(ukeys);
6656 std::vector<std::string> uniqueError;
6657 for(int32_t q = 0; q < num_ukey; ++q)
6658 {
6659 for(int32_t p = q+1; p < num_ukey; ++p)
6660 {
6661 if(ukeys[q] == ukeys[p] && ukeys[q] != 0)
6662 {
6663 char buf[64];
6664 sprintf(buf, "'%s' conflicts with '%s'", get_ukey_name(q).c_str(), get_ukey_name(p).c_str());
6665 std::string str(buf);
6666 uniqueError.push_back(str);
6667 }
6668 }
6669 }
6670 if(uniqueError.size() == 0)
6671 {
6672 done = true;
6673 save_control_configs(true);
6674 }
6675 else
6676 {
6677 box_start(1, "Duplicate Keys", get_zc_font(font_lfont), get_zc_font(font_sfont), false, keyboard_control_dlg[0].w,keyboard_control_dlg[0].h, 2);
6678 box_out("Cannot have duplicate keybinds!"); box_eol();
6679 for(std::vector<std::string>::iterator it = uniqueError.begin();
6680 it != uniqueError.end(); ++it)
6681 {
6682 box_out((*it).c_str()); box_eol();
6683 }
6684 box_end(true);
6685 }
6686 }
6687 else // Cancel
6688 {
6689 Akey = a;
6690 Bkey = b;
6691 Skey = s;
6692 Lkey = l;
6693 Rkey = r;
6694 Pkey = p;
6695 Exkey1 = ex1;
6696 Exkey2 = ex2;
6697 Exkey3 = ex3;
6698 Exkey4 = ex4;
6699 DUkey = du;
6700 DDkey = dd;
6701 DLkey = dl;
6702 DRkey = dr;
6703 cheat_modifier_keys[0] = mod1a;
6704 cheat_modifier_keys[1] = mod1b;
6705 cheat_modifier_keys[2] = mod2a;
6706 cheat_modifier_keys[3] = mod2b;
6707
6708 done=true;
6709 }
6710
6711 rest(1);
6712 }
6713
6714 return D_O_K;
6715 }
6716
6717 int32_t onGamepad()
6718 {
6719 int32_t a = Abtn;
6720 int32_t b = Bbtn;
6721 int32_t s = Sbtn;
6722 int32_t l = Lbtn;
6723 int32_t r = Rbtn;
6724 int32_t m = Mbtn;
6725 int32_t p = Pbtn;
6726 int32_t ex1 = Exbtn1;
6727 int32_t ex2 = Exbtn2;
6728 int32_t ex3 = Exbtn3;
6729 int32_t ex4 = Exbtn4;
6730 int32_t up = DUbtn;
6731 int32_t down = DDbtn;
6732 int32_t left = DLbtn;
6733 int32_t right = DRbtn;
6734 int32_t joy = joystick_index;
6735 int32_t stick_1 = js_stick_1_x_stick;
6736 int32_t stick_2 = js_stick_2_x_stick;
6737
6738 gamepad_dlg[0].dp2=get_zc_font(font_lfont);
6739 if(analog_movement)
6740 gamepad_dlg[56].flags|=D_SELECTED;
6741 else
6742 gamepad_dlg[56].flags&=~D_SELECTED;
6743
6744 // TODO: should use controller device GUID or name instead of index, otherwise this value is not
6745 // consistent unless exact same number of joysticks is always connected. Name is problematic b/c
6746 // xinput driver doesn't actually get a name (at least, doesn't for my Xbox controller).
6747 // TODO: should store gamepad control mappings per-controller, otherwise switching joystick
6748 // requires remapping every time.
6749 if (joystick_index >= al_get_num_joysticks())
6750 joystick_index = 0;
6751 gamepad_dlg[61].d2 = joystick_index;
6752
6753 large_dialog(gamepad_dlg);
6754
6755 int32_t ret = do_zqdialog(gamepad_dlg,4);
6756
6757 if(ret == 4) //OK
6758 {
6759 analog_movement = gamepad_dlg[56].flags&D_SELECTED;
6760 joystick_index = gamepad_dlg[61].d2;
6761 js_stick_1_y_stick = js_stick_1_x_stick;
6762 js_stick_2_y_stick = js_stick_2_x_stick;
6763 save_control_configs(false);
6764 }
6765 else //Cancel
6766 {
6767 Abtn = a;
6768 Bbtn = b;
6769 Sbtn = s;
6770 Lbtn = l;
6771 Rbtn = r;
6772 Mbtn = m;
6773 Pbtn = p;
6774 Exbtn1 = ex1;
6775 Exbtn2 = ex2;
6776 Exbtn3 = ex3;
6777 Exbtn4 = ex4;
6778 DUbtn = up;
6779 DDbtn = down;
6780 DLbtn = left;
6781 DRbtn = right;
6782 joystick_index = joy;
6783 js_stick_1_x_stick = stick_1;
6784 js_stick_2_x_stick = stick_2;
6785 }
6786
6787 return D_O_K;
6788 }
6789
6790 int32_t onCheatKeys()
6791 {
6792 int32_t oldcheats[Cheat::Last][2];
6793 memcpy(oldcheats, cheatkeys, sizeof(cheatkeys));
6794
6795 bool done=false;
6796
6797 while(!done)
6798 {
6799 bool confirm = false;
6800 CheatKeysDialog(&confirm).show();
6801 if(confirm) // OK
6802 {
6803 std::vector<std::string> uniqueError;
6804 char buf[512];
6805 for(size_t q = 1; q < Cheat::Last; ++q)
6806 {
6807 if(cheatkeys[q][1] && !cheatkeys[q][0])
6808 {
6809 cheatkeys[q][0] = cheatkeys[q][1];
6810 cheatkeys[q][1] = 0;
6811 }
6812 }
6813 for(size_t q = 1; q < Cheat::Last; ++q)
6814 {
6815 if(!bindable_cheat((Cheat)q)) continue;
6816 for(size_t p = q+1; p < Cheat::Last; ++p)
6817 {
6818 if(!bindable_cheat((Cheat)p)) continue;
6819 for(size_t q2 = 0; q2 <= 1; ++q2)
6820 for(size_t p2 = 0; p2 <= 1; ++p2)
6821 {
6822 if(cheatkeys[q][q2] == cheatkeys[p][p2] && cheatkeys[q][q2] != 0)
6823 {
6824 uniqueError.push_back(fmt::format("'{}' ({}) conflicts with '{}' ({}) - both '{}'",
6825 cheat_to_string((Cheat)q), q2?"Alt":"Main",
6826 cheat_to_string((Cheat)p), p2?"Alt":"Main",
6827 get_keystr(cheatkeys[q][q2])));
6828 }
6829 }
6830 }
6831 }
6832 if(uniqueError.size() == 0)
6833 {
6834 done = true;
6835 save_cheatkeys();
6836 }
6837 else
6838 {
6839 box_start(1, "Duplicate Keys", get_zc_font(font_lfont), get_zc_font(font_sfont), false, 500,400, 2);
6840 box_out("Cannot have duplicate keybinds!"); box_eol();
6841 for(std::vector<std::string>::iterator it = uniqueError.begin();
6842 it != uniqueError.end(); ++it)
6843 {
6844 box_out((*it).c_str()); box_eol();
6845 }
6846 box_end(true);
6847 }
6848 }
6849 else // Cancel
6850 {
6851 memcpy(cheatkeys, oldcheats, sizeof(cheatkeys));
6852 done=true;
6853 }
6854 rest(1);
6855 }
6856
6857 return D_O_K;
6858 }
6859
6860 int32_t onSound()
6861 {
6862 if (get_qr(qr_OLD_SCRIPT_VOLUME))
6863 {
6864 if (FFCore.coreflags & FFCORE_SCRIPTED_MIDI_VOLUME)
6865 {
6866 master_volume(-1, ((int32_t)FFCore.usr_midi_volume));
6867 }
6868 if (FFCore.coreflags & FFCORE_SCRIPTED_DIGI_VOLUME)
6869 {
6870 master_volume((int32_t)(FFCore.usr_digi_volume), 1);
6871 }
6872 if (FFCore.coreflags & FFCORE_SCRIPTED_MUSIC_VOLUME)
6873 {
6874 emusic_volume = (int32_t)FFCore.usr_music_volume;
6875 }
6876 if (FFCore.coreflags & FFCORE_SCRIPTED_SFX_VOLUME)
6877 {
6878 sfx_volume = (int32_t)FFCore.usr_sfx_volume;
6879 }
6880 }
6881 if ( FFCore.coreflags&FFCORE_SCRIPTED_PANSTYLE )
6882 {
6883 pan_style = (int32_t)FFCore.usr_panstyle;
6884 }
6885
6886 int32_t m = midi_volume;
6887 int32_t d = digi_volume;
6888 int32_t e = emusic_volume;
6889 int32_t b = zcmusic_bufsz;
6890 int32_t s = sfx_volume;
6891 int32_t p = pan_style;
6892 pan_style = vbound(pan_style,0,3);
6893
6894 sound_dlg[0].dp2=get_zc_font(font_lfont);
6895
6896 large_dialog(sound_dlg);
6897
6898 midi_dp[1] = sound_dlg[6].x;
6899 midi_dp[2] = sound_dlg[6].y;
6900 digi_dp[1] = sound_dlg[7].x;
6901 digi_dp[2] = sound_dlg[7].y;
6902 emus_dp[1] = sound_dlg[8].x;
6903 emus_dp[2] = sound_dlg[8].y;
6904 buf_dp[1] = sound_dlg[9].x;
6905 buf_dp[2] = sound_dlg[9].y;
6906 sfx_dp[1] = sound_dlg[10].x;
6907 sfx_dp[2] = sound_dlg[10].y;
6908 pan_dp[1] = sound_dlg[11].x;
6909 pan_dp[2] = sound_dlg[11].y;
6910 sound_dlg[15].d2 = (midi_volume==255) ? 32 : midi_volume>>3;
6911 sound_dlg[16].d2 = (digi_volume==255) ? 32 : digi_volume>>3;
6912 sound_dlg[17].d2 = (emusic_volume==255) ? 32 : emusic_volume>>3;
6913 sound_dlg[18].d2 = zcmusic_bufsz;
6914 sound_dlg[19].d2 = (sfx_volume==255) ? 32 : sfx_volume>>3;
6915 sound_dlg[20].d2 = pan_style;
6916
6917 int32_t ret = do_zqdialog(sound_dlg,1);
6918
6919 if(ret==2)
6920 {
6921 master_volume(digi_volume,midi_volume);
6922 if (zcmusic)
6923 zcmusic_set_volume(zcmusic, emusic_volume);
6924
6925 int32_t temp_volume = sfx_volume;
6926 if (GameLoaded && !get_qr(qr_OLD_SCRIPT_VOLUME))
6927 temp_volume = (sfx_volume * FFCore.usr_sfx_volume) / 10000 / 100;
6928 for(int32_t i=0; i<WAV_COUNT; ++i)
6929 {
6930 //allegro assertion fails when passing in -1 as voice -DD
6931 if(sfx_voice[i] > 0)
6932 voice_set_volume(sfx_voice[i], temp_volume);
6933 }
6934 zc_set_config(sfx_sect,"digi",digi_volume);
6935 zc_set_config(sfx_sect,"midi",midi_volume);
6936 zc_set_config(sfx_sect,"sfx",sfx_volume);
6937 zc_set_config(sfx_sect,"emusic",emusic_volume);
6938 zc_set_config(sfx_sect,"pan",pan_style);
6939 zc_set_config(sfx_sect,"zcmusic_bufsz",zcmusic_bufsz);
6940 }
6941 else
6942 {
6943 midi_volume = m;
6944 digi_volume = d;
6945 emusic_volume = e;
6946 zcmusic_bufsz = b;
6947 sfx_volume = s;
6948 pan_style = p;
6949 }
6950
6951 return D_O_K;
6952 }
6953
6954 int32_t queding(char const* s1, char const* s2, char const* s3)
6955 {
6956 return jwin_alert("ZQuest Classic",s1,s2,s3,"&Yes","&No",'y','n',get_zc_font(font_lfont));
6957 }
6958
6959 int32_t onQuit()
6960 {
6961 if(Playing)
6962 {
6963 int32_t ret=0;
6964
6965 if(get_qr(qr_NOCONTINUE))
6966 {
6967 if(standalone_mode)
6968 {
6969 ret=queding("End current game?",
6970 "The continue screen is disabled; the game",
6971 "will be reloaded from the last save.");
6972 }
6973 else
6974 {
6975 ret=queding("End current game?",
6976 "The continue screen is disabled. You will",
6977 "be returned to the file select screen.");
6978 }
6979 }
6980 else
6981 ret=queding("End current game?",NULL,NULL);
6982
6983 if(ret==1)
6984 {
6985 disableClickToFreeze=false;
6986 Quit=qQUIT;
6987
6988 // Trying to evade a door repair charge?
6989 if(repaircharge)
6990 {
6991 game->change_drupy(-repaircharge);
6992 repaircharge=0;
6993 }
6994
6995 return D_CLOSE;
6996 }
6997 }
6998
6999 return D_O_K;
7000 }
7001
7002 int32_t onTryQuitMenu()
7003 {
7004 return onTryQuit(true);
7005 }
7006
7007 int32_t onTryQuit(bool inMenu)
7008 {
7009 if(Playing && !(GameFlags & GAMEFLAG_NO_F6))
7010 {
7011 if(active_cutscene.can_f6())
7012 {
7013 if(get_qr(qr_OLD_F6))
7014 {
7015 if(inMenu) onQuit();
7016 else /*if(!get_qr(qr_NOCONTINUE))*/ f_Quit(qQUIT);
7017 }
7018 else
7019 {
7020 disableClickToFreeze=false;
7021 GameFlags |= GAMEFLAG_TRYQUIT;
7022 }
7023 return D_CLOSE;
7024 }
7025 else active_cutscene.error();
7026 }
7027
7028 return D_O_K;
7029 }
7030
7031 int32_t onReset()
7032 {
7033 if(queding(" Reset system? ",NULL,NULL)==1)
7034 {
7035 disableClickToFreeze=false;
7036 Quit=qRESET;
7037 replay_quit();
7038 return D_CLOSE;
7039 }
7040
7041 return D_O_K;
7042 }
7043
7044 int32_t onExit()
7045 {
7046 if(queding(" Quit ZQuest Classic? ",NULL,NULL)==1)
7047 {
7048 Quit=qEXIT;
7049 return D_CLOSE;
7050 }
7051
7052 return D_O_K;
7053 }
7054
7055 int32_t onDebug()
7056 {
7057 if(debug_enabled)
7058 set_debug(!get_debug());
7059 return D_O_K;
7060 }
7061
7062 int32_t onHeartBeep()
7063 {
7064 heart_beep=!heart_beep;
7065 zc_set_config(cfg_sect,"heart_beep",heart_beep);
7066 return D_O_K;
7067 }
7068
7069 int32_t onSaveIndicator()
7070 {
7071 use_save_indicator = use_save_indicator ? 0 : 1;
7072 zc_set_config(cfg_sect,"save_indicator",use_save_indicator);
7073 return D_O_K;
7074 }
7075
7076 int32_t onEpilepsy()
7077 {
7078 if(jwin_alert3(
7079 "Epilepsy Flash Reduction",
7080 "Enabling this will reduce the intensity of flashing and screen wave effects.",
7081 "Disabling this will restore standard flash and wavy behaviour.",
7082 "Proceed?",
7083 "&Yes",
7084 "&No",
7085 NULL,
7086 'y',
7087 'n',
7088 0,
7089 get_zc_font(font_lfont)) == 1)
7090 {
7091 epilepsyFlashReduction = epilepsyFlashReduction ? 0 : 1;
7092 zc_set_config("zeldadx","checked_epilepsy",1);
7093 zc_set_config(cfg_sect,"epilepsy_flash_reduction",epilepsyFlashReduction);
7094 }
7095 return D_O_K;
7096 }
7097
7098 int32_t onTriforce()
7099 {
7100 for(int32_t i=0; i<MAXINITTABS; ++i)
7101 {
7102 init_tabs[i].flags&=~D_SELECTED;
7103 }
7104
7105 init_tabs[3].flags=D_SELECTED;
7106 return onCheatConsole();
7107 /*triforce_dlg[0].dp2=get_zc_font(font_lfont);
7108 for(int32_t i=1; i<=8; i++)
7109 triforce_dlg[i].flags = (game->lvlitems[i] & liTRIFORCE) ? D_SELECTED : 0;
7110
7111 if(do_zqdialog (triforce_dlg,-1)==9)
7112 {
7113 for(int32_t i=1; i<=8; i++)
7114 {
7115 game->lvlitems[i] &= ~liTRIFORCE;
7116 game->lvlitems[i] |= (triforce_dlg[i].flags & D_SELECTED) ? liTRIFORCE : 0;
7117 }
7118 }
7119 return D_O_K;*/
7120 }
7121
7122 bool rc = false;
7123 /*
7124 int32_t onEquipment()
7125 {
7126 for (int32_t i=0; i<MAXINITTABS; ++i)
7127 {
7128 init_tabs[i].flags&=~D_SELECTED;
7129 }
7130 init_tabs[0].flags=D_SELECTED;
7131 return onCheatConsole();
7132 }
7133 */
7134
7135 int32_t onItems()
7136 {
7137 for(int32_t i=0; i<MAXINITTABS; ++i)
7138 {
7139 init_tabs[i].flags&=~D_SELECTED;
7140 }
7141
7142 init_tabs[1].flags=D_SELECTED;
7143 return onCheatConsole();
7144 }
7145
7146 static DIALOG getnum_dlg[] =
7147 {
7148 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
7149 { jwin_win_proc, 80, 80, 160, 72, vc(0), vc(11), 0, D_EXIT, 0, 0, NULL, NULL, NULL },
7150 { jwin_text_proc, 104, 104+4, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Number:", NULL, NULL },
7151 { jwin_edit_proc, 168, 104, 48, 16, 0, 0, 0, 0, 6, 0, NULL, NULL, NULL },
7152 { jwin_button_proc, 90, 126, 61, 21, vc(0), vc(11), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
7153 { jwin_button_proc, 170, 126, 61, 21, vc(0), vc(11), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
7154 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
7155 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
7156 };
7157
7158 int32_t getnumber(const char *prompt,int32_t initialval)
7159 {
7160 char buf[20];
7161 sprintf(buf,"%d",initialval);
7162 getnum_dlg[0].dp=(void *)prompt;
7163 getnum_dlg[0].dp2=get_zc_font(font_lfont);
7164 getnum_dlg[2].dp=buf;
7165
7166 large_dialog(getnum_dlg);
7167
7168 if(do_zqdialog(getnum_dlg,2)==3)
7169 return atoi(buf);
7170
7171 return initialval;
7172 }
7173
7174 int32_t onLife()
7175 {
7176 int value = vbound(getnumber("Life",game->get_life()),1,game->get_maxlife());
7177 cheats_enqueue(Cheat::Life, value);
7178 return D_O_K;
7179 }
7180
7181 int32_t onHeartC()
7182 {
7183 int max_life = vbound(getnumber("Heart Containers",game->get_maxlife()/game->get_hp_per_heart()),1,4095) * game->get_hp_per_heart();
7184 int life = vbound(getnumber("Life",game->get_life()/game->get_hp_per_heart()),1,max_life/game->get_hp_per_heart())*game->get_hp_per_heart();
7185 cheats_enqueue(Cheat::MaxLife, max_life);
7186 cheats_enqueue(Cheat::Life, life);
7187 return D_O_K;
7188 }
7189
7190 int32_t onMagicC()
7191 {
7192 int max_magic = vbound(getnumber("Magic Containers",game->get_maxmagic()/game->get_mp_per_block()),0,2047) * game->get_mp_per_block();
7193 int magic = vbound(getnumber("Magic",game->get_magic()/game->get_mp_per_block()),0,max_magic/game->get_mp_per_block())*game->get_mp_per_block();
7194 cheats_enqueue(Cheat::MaxMagic, max_magic);
7195 cheats_enqueue(Cheat::Magic, magic);
7196 return D_O_K;
7197 }
7198
7199 int32_t onRupies()
7200 {
7201 int value = vbound(getnumber("Rupees",game->get_rupies()),0,game->get_maxcounter(1));
7202 cheats_enqueue(Cheat::Rupies, value);
7203 return D_O_K;
7204 }
7205
7206 int32_t onMaxBombs()
7207 {
7208 int value = vbound(getnumber("Max Bombs",game->get_maxbombs()),0,0xFFFF);
7209 cheats_enqueue(Cheat::MaxBombs, value);
7210 cheats_enqueue(Cheat::Bombs, value);
7211 return D_O_K;
7212 }
7213
7214 int32_t onRefillLife()
7215 {
7216 cheats_enqueue(Cheat::Life, game->get_maxlife());
7217 return D_O_K;
7218 }
7219 int32_t onRefillMagic()
7220 {
7221 cheats_enqueue(Cheat::Magic, game->get_maxmagic());
7222 return D_O_K;
7223 }
7224 int32_t onClock()
7225 {
7226 cheats_enqueue(Cheat::Clock);
7227 return D_O_K;
7228 }
7229
7230 int32_t onQstPath()
7231 {
7232 char path[2048];
7233
7234 chop_path(qstdir);
7235 strcpy(path,qstdir);
7236
7237 go();
7238
7239 if(jwin_dfile_select_ex("Quest File Directory", path, "qst", 2048, -1, -1, get_zc_font(font_lfont)))
7240 {
7241 chop_path(path);
7242 fix_filename_case(path);
7243 fix_filename_slashes(path);
7244 strcpy(qstdir,path);
7245 strcpy(qstpath,qstdir);
7246 }
7247
7248 comeback();
7249 return D_O_K;
7250 }
7251
7252 #include "dialog/cheat_dialog.h"
7253 int32_t onCheat()
7254 {
7255 call_setcheat_dialog();
7256 game->set_cheat(maxcheat);
7257 if(cheat) game->did_cheat(true);
7258 return D_O_K;
7259 }
7260
7261 int32_t onCheatRupies()
7262 {
7263 cheats_enqueue(Cheat::Rupies, game->get_maxcounter(1));
7264 return D_O_K;
7265 }
7266
7267 int32_t onCheatArrows()
7268 {
7269 cheats_enqueue(Cheat::Arrows, game->get_maxarrows());
7270 return D_O_K;
7271 }
7272
7273 int32_t onCheatBombs()
7274 {
7275 cheats_enqueue(Cheat::Bombs, game->get_maxbombs(), game->get_maxcounter(6));
7276 return D_O_K;
7277 }
7278
7279 // *** screen saver
7280
7281 9286678 int32_t after_time()
7282 {
7283
1/2
✓ Branch 0 taken 9286678 times.
✗ Branch 1 not taken.
9286678 if(ss_enable == 0)
7284 return INT_MAX;
7285
7286
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9286678 times.
9286678 if(ss_after <= 0)
7287 return 5 * 60;
7288
7289
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9286678 times.
9286678 if(ss_after <= 3)
7290 return ss_after * 15 * 60;
7291
7292
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9286678 times.
9286678 if(ss_after <= 13)
7293 return (ss_after - 3) * 60 * 60;
7294
7295 9286678 return MAX_IDLE + 1;
7296 9286678 }
7297
7298 static const char *after_str[15] =
7299 {
7300 " 5 sec", "15 sec", "30 sec", "45 sec", " 1 min", " 2 min", " 3 min",
7301 " 4 min", " 5 min", " 6 min", " 7 min", " 8 min", " 9 min", "10 min",
7302 "Never"
7303 };
7304
7305 const char *after_list(int32_t index, int32_t *list_size)
7306 {
7307 if(index < 0)
7308 {
7309 *list_size = 15;
7310 return NULL;
7311 }
7312
7313 return after_str[index];
7314 }
7315
7316 116 static ListData after__list(after_list, &font);
7317
7318 static DIALOG scrsaver_dlg[] =
7319 {
7320 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
7321 116 { jwin_win_proc, 32, 64, 256, 136, 0, 0, 0, D_EXIT, 0, 0, (void *) "Screen Saver Settings", NULL, NULL },
7322 116 { jwin_frame_proc, 42, 92, 236, 70, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
7323 116 { jwin_text_proc, 60, 104, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Run After", NULL, NULL },
7324 116 { jwin_text_proc, 60, 128, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Speed", NULL, NULL },
7325 116 { jwin_text_proc, 60, 144, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Density", NULL, NULL },
7326 116 { jwin_droplist_proc, 144, 100, 96, 16, 0, 0, 0, 0, 0, 0, (void *) &after__list, NULL, NULL },
7327 116 { jwin_slider_proc, 144, 128, 116, 8, vc(0), jwin_pal[jcBOX], 0, 0, 6, 0, NULL, NULL, NULL },
7328 116 { jwin_slider_proc, 144, 144, 116, 8, vc(0), jwin_pal[jcBOX], 0, 0, 6, 0, NULL, NULL, NULL },
7329 116 { jwin_button_proc, 42, 170, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
7330 116 { jwin_button_proc, 124, 170, 72, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Preview", NULL, NULL },
7331 116 { jwin_button_proc, 218, 170, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
7332 116 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
7333 116 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
7334 };
7335
7336 int32_t onScreenSaver()
7337 {
7338 scrsaver_dlg[0].dp2=get_zc_font(font_lfont);
7339 int32_t oldcfgs[3];
7340 scrsaver_dlg[5].d1 = scrsaver_dlg[5].d2 = oldcfgs[0] = ss_after;
7341 scrsaver_dlg[6].d2 = oldcfgs[1] = ss_speed;
7342 scrsaver_dlg[7].d2 = oldcfgs[2] = ss_density;
7343
7344 large_dialog(scrsaver_dlg);
7345
7346 int32_t ret = do_zqdialog(scrsaver_dlg,-1);
7347
7348 if(ret == 8 || ret == 9)
7349 {
7350 ss_after = scrsaver_dlg[5].d1;
7351 ss_speed = scrsaver_dlg[6].d2;
7352 ss_density = scrsaver_dlg[7].d2;
7353 if(oldcfgs[0] != ss_after)
7354 zc_set_config(cfg_sect,"ss_after",ss_after);
7355 if(oldcfgs[1] != ss_speed)
7356 zc_set_config(cfg_sect,"ss_speed",ss_speed);
7357 if(oldcfgs[2] != ss_density)
7358 zc_set_config(cfg_sect,"ss_density",ss_density);
7359 }
7360
7361 if(ret == 9)
7362 // preview Screen Saver
7363 {
7364 clear_keybuf();
7365 Matrix(ss_speed, ss_density, 30);
7366 system_pal(true);
7367 sys_mouse();
7368 }
7369
7370 return D_O_K;
7371 }
7372
7373 /***** Menus *****/
7374
7375 static MENU game_menu[] =
7376 {
7377 { (char *)"&Continue\tESC", onContinue, NULL, 0, NULL },
7378 { (char *)"", NULL, NULL, 0, NULL },
7379 { (char *)"L&oad Quest...", onCustomGame, NULL, 0, NULL },
7380 { (char *)"&End Game\tF6", onTryQuitMenu, NULL, 0, NULL },
7381 { (char *)"", NULL, NULL, 0, NULL },
7382 #ifdef __EMSCRIPTEN__
7383 { (char *)"&Reset\tF7", onReset, NULL, 0, NULL },
7384 #elif defined(ALLEGRO_MACOSX)
7385 { (char *)"&Reset\tF7", onReset, NULL, 0, NULL },
7386 { (char *)"&Quit\tF8", onExit, NULL, 0, NULL },
7387 #else
7388 { (char *)"&Reset\tF9", onReset, NULL, 0, NULL },
7389 { (char *)"&Quit\tF10", onExit, NULL, 0, NULL },
7390 #endif
7391 { NULL, NULL, NULL, 0, NULL }
7392 };
7393
7394 static MENU snapshot_format_menu[] =
7395 {
7396 { (char *)"&BMP", onSetSnapshotFormat, NULL, 0, NULL },
7397 { (char *)"&GIF", onSetSnapshotFormat, NULL, 0, NULL },
7398 { (char *)"&JPG", onSetSnapshotFormat, NULL, 0, NULL },
7399 { (char *)"&PNG", onSetSnapshotFormat, NULL, 0, NULL },
7400 { (char *)"PC&X", onSetSnapshotFormat, NULL, 0, NULL },
7401 { (char *)"&TGA", onSetSnapshotFormat, NULL, 0, NULL },
7402 { NULL, NULL, NULL, 0, NULL }
7403 };
7404
7405 static MENU controls_menu[] =
7406 {
7407 { (char *)"Key&board...", onKeyboard, NULL, 0, NULL },
7408 { (char *)"&Gamepad...", onGamepad, NULL, 0, NULL },
7409 { (char *)"&Cheat Keys...", onCheatKeys, NULL, 0, NULL },
7410 { NULL, NULL, NULL, 0, NULL }
7411 };
7412
7413 static MENU name_entry_mode_menu[] =
7414 {
7415 { (char *)"&Keyboard", onKeyboardEntry, NULL, 0, NULL },
7416 { (char *)"&Letter Grid", onLetterGridEntry, NULL, 0, NULL },
7417 { (char *)"&Extended Letter Grid", onExtLetterGridEntry, NULL, 0, NULL },
7418 { NULL, NULL, NULL, 0, NULL }
7419 };
7420
7421 static void set_controls_menu_active()
7422 {
7423
7424 }
7425
7426 static MENU window_menu[] =
7427 {
7428 { "Lock Aspect Ratio", onDragAspect, NULL, 0, NULL },
7429 { "Lock Integer Scale", onIntegerScaling, NULL, 0, NULL },
7430 { "Save Size Changes", onSaveDragResize, NULL, 0, NULL },
7431 { "Save Position Changes", onWinPosSave, NULL, 0, NULL },
7432 { "Stretch Game Area", onStretchGame, NULL, 0, NULL },
7433 { NULL, NULL, NULL, 0, NULL }
7434 };
7435 static MENU options_menu[] =
7436 {
7437 { "Name &Entry Mode", NULL, name_entry_mode_menu, 0, NULL },
7438 { "S&napshot Format", NULL, snapshot_format_menu, 0, NULL },
7439 { "&Window Settings", NULL, window_menu, 0, NULL },
7440 { "Epilepsy Flash Reduction", onEpilepsy, NULL, 0, NULL },
7441 { "Pause In Background", onPauseInBackground, NULL, 0, NULL },
7442 { NULL, NULL, NULL, 0, NULL }
7443 };
7444 static MENU settings_menu[] =
7445 {
7446 { "&Sound...", onSound, NULL, 0, NULL },
7447 { "C&ontrols", NULL, controls_menu, 0, NULL },
7448 { "", NULL, NULL, 0, NULL },
7449 { "Options", NULL, options_menu, 0, NULL },
7450 { "", NULL, NULL, 0, NULL },
7451 //
7452 { "&Cap FPS\tF1", onVsync, NULL, 0, NULL },
7453 { "Show &FPS\tF2", onShowFPS, NULL, 0, NULL },
7454 { "Click to Freeze", onClickToFreeze, NULL, 0, NULL },
7455 { "Cont. &Heart Beep", onHeartBeep, NULL, 0, NULL },
7456 { "Show Trans. &Layers", onTransLayers, NULL, 0, NULL },
7457 //
7458 { "Up+A+B To &Quit", onNESquit, NULL, 0, NULL },
7459 { "Volume &Keys", onVolKeys, NULL, 0, NULL },
7460 { "Sa&ve Indicator", onSaveIndicator, NULL, 0, NULL },
7461 { "", NULL, NULL, 0, NULL },
7462 { "Debu&g", onDebug, NULL, 0, NULL },
7463 //
7464 { NULL, NULL, NULL, 0, NULL }
7465 };
7466
7467
7468 static MENU misc_menu[] =
7469 {
7470 { (char *)"&About...", onAbout, NULL, 0, NULL },
7471 // TODO: re-enable, but: 1) do not use a bitmap thing that is hard to update 2) update names and 3) don't use the Z-word.
7472 { (char *)"&Credits...", onCredits, NULL, D_DISABLED, NULL },
7473 { (char *)"&Fullscreen", onFullscreenMenu, NULL, 0, NULL },
7474 { (char *)"&Video Mode...", onVidMode, NULL, 0, NULL },
7475 { (char *)"", NULL, NULL, 0, NULL },
7476 //5
7477 { (char *)"&Quest Info...", onQuest, NULL, 0, NULL },
7478 { (char *)"Quest &MIDI Info...", onMIDICredits, NULL, 0, NULL },
7479 { (char *)"Quest &Directory...", onQstPath, NULL, 0, NULL },
7480 { (char *)"", NULL, NULL, 0, NULL },
7481 { (char *)"Take &Snapshot\tF12", onSnapshot, NULL, 0, NULL },
7482 //10
7483 { (char *)"Sc&reen Saver...", onScreenSaver, NULL, 0, NULL },
7484 { (char *)"Save ZC Configuration", OnSaveZCConfig, NULL, 0, NULL },
7485 { (char *)"Show ZASM Debugger", onConsoleZASM, NULL, 0, NULL },
7486 { (char *)"Show ZScript Debugger", onConsoleZScript, NULL, 0, NULL },
7487 { (char *)"Clear Console on Qst Load", onClrConsoleOnLoad, NULL, 0, NULL },
7488 //15
7489 { (char *)"Clear Directory Cache", OnnClearQuestDir, NULL, 0, NULL },
7490 { NULL, NULL, NULL, 0, NULL }
7491 };
7492
7493 static MENU refill_menu[] =
7494 {
7495 { (char *)"&Life", onRefillLife, NULL, 0, NULL },
7496 { (char *)"&Magic", onRefillMagic, NULL, 0, NULL },
7497 { (char *)"&Bombs", onCheatBombs, NULL, 0, NULL },
7498 { (char *)"&Rupees", onCheatRupies, NULL, 0, NULL },
7499 { (char *)"&Arrows", onCheatArrows, NULL, 0, NULL },
7500 { NULL, NULL, NULL, 0, NULL }
7501 };
7502
7503 static MENU show_menu[] =
7504 {
7505 { (char *)"Combos", onShowLayer0, NULL, 0, NULL },
7506 { (char *)"Layer 1", onShowLayer1, NULL, 0, NULL },
7507 { (char *)"Layer 2", onShowLayer2, NULL, 0, NULL },
7508 { (char *)"Layer 3", onShowLayer3, NULL, 0, NULL },
7509 { (char *)"Layer 4", onShowLayer4, NULL, 0, NULL },
7510 { (char *)"Layer 5", onShowLayer5, NULL, 0, NULL },
7511 { (char *)"Layer 6", onShowLayer6, NULL, 0, NULL },
7512 { (char *)"Overhead Combos", onShowLayerO, NULL, 0, NULL },
7513 { (char *)"Push Blocks", onShowLayerP, NULL, 0, NULL },
7514 { (char *)"Freeform Combos", onShowLayerF, NULL, 0, NULL },
7515 { (char *)"Sprites", onShowLayerS, NULL, 0, NULL },
7516 { (char *)"", NULL, NULL, 0, NULL },
7517 { (char *)"Current FFC Scripts", onShowFFScripts, NULL, 0, NULL },
7518 { (char *)"", NULL, NULL, 0, NULL },
7519 { (char *)"Walkability", onShowLayerW, NULL, 0, NULL },
7520 { (char *)"Hitboxes", onShowHitboxes, NULL, 0, NULL },
7521 { (char *)"Effects", onShowLayerE, NULL, 0, NULL },
7522 { (char *)"Info Opacity", onShowInfoOpacity, NULL, 0, NULL },
7523 { NULL, NULL, NULL, 0, NULL }
7524 };
7525
7526 static MENU cheat_menu[] =
7527 {
7528 { (char *)"Set &Cheat", onCheat, NULL, 0, NULL },
7529 { (char *)"", NULL, NULL, 0, NULL },
7530 { (char *)"Re&fill", NULL, refill_menu, 0, NULL },
7531 { (char *)"", NULL, NULL, 0, NULL },
7532 { (char *)"&Invincible", onClock, NULL, 0, NULL },
7533 { (char *)"Ma&x Bombs...", onMaxBombs, NULL, 0, NULL },
7534 { (char *)"&Heart Containers...", onHeartC, NULL, 0, NULL },
7535 { (char *)"&Magic Containers...", onMagicC, NULL, 0, NULL },
7536 { (char *)"", NULL, NULL, 0, NULL },
7537 { (char *)"&Player Data...", onCheatConsole, NULL, 0, NULL },
7538 { (char *)"", NULL, NULL, 0, NULL },
7539 { (char *)"Walk Through &Walls", onNoWalls, NULL, 0, NULL },
7540 { (char *)"Player Ignores Side&view", onIgnoreSideview, NULL, 0, NULL },
7541 { (char *)"&Quick Movement", onGoFast, NULL, 0, NULL },
7542 { (char *)"&Kill All Enemies", onKillCheat, NULL, 0, NULL },
7543 { (char *)"Trigger &Secrets", onSecretsCheat, NULL, 0, NULL },
7544 { (char *)"Trigger Secrets Perm", onSecretsCheatPerm, NULL, 0, NULL },
7545 { (char *)"Show/Hide Layer", NULL, show_menu, 0, NULL },
7546 { (char *)"Toggle &Light", onLightSwitch, NULL, 0, NULL },
7547 { (char *)"&Goto Location...", onGoTo, NULL, 0, NULL },
7548 { NULL, NULL, NULL, 0, NULL }
7549 };
7550
7551 #if DEVLEVEL > 0
7552 int32_t devLogging();
7553 int32_t devDebug();
7554 int32_t devTimestmp();
7555 #if DEVLEVEL > 1
7556 int32_t setCheat();
7557 #endif //DEVLEVEL > 1
7558 enum
7559 {
7560 dv_log,
7561 // dv_dbg,
7562 dv_tmpstmp,
7563 #if DEVLEVEL > 1
7564 dv_nil,
7565 dv_setcheat,
7566 #endif //DEVLEVEL > 1
7567 dv_max
7568 };
7569 static MENU dev_menu[] =
7570 {
7571 { (char *)"&Force Error Log", devLogging, NULL, 0, NULL },
7572 // { (char *)"&Extra Debug Log", devDebug, NULL, 0, NULL },
7573 { (char *)"&Timestamp Log", devTimestmp, NULL, 0, NULL },
7574 #if DEVLEVEL > 1
7575 { (char *)"", NULL, NULL, 0, NULL },
7576 { (char *)"Set &Cheat", setCheat, NULL, 0, NULL },
7577 #endif //DEVLEVEL > 1
7578 { NULL, NULL, NULL, 0, NULL }
7579 };
7580 int32_t devLogging()
7581 {
7582 dev_logging = !dev_logging;
7583 dev_menu[dv_log].flags = dev_logging ? D_SELECTED : 0;
7584 return D_O_K;
7585 }
7586 // int32_t devDebug()
7587 // {
7588 // dev_debug = !dev_debug;
7589 // dev_menu[dv_dbg].flags = dev_debug ? D_SELECTED : 0;
7590 // return D_O_K;
7591 // }
7592 int32_t devTimestmp()
7593 {
7594 dev_timestmp = !dev_timestmp;
7595 dev_menu[dv_tmpstmp].flags = dev_timestmp ? D_SELECTED : 0;
7596 return D_O_K;
7597 }
7598 #if DEVLEVEL > 1
7599 int32_t setCheat()
7600 {
7601 cheat = (vbound(getnumber("Cheat Level",cheat), 0, 4));
7602 return D_O_K;
7603 }
7604 #endif //DEVLEVEL > 1
7605 #endif //DEVLEVEL > 0
7606
7607 MENU the_player_menu[] =
7608 {
7609 { (char *)"&Game", NULL, game_menu, 0, NULL },
7610 { (char *)"&Settings", NULL, settings_menu, 0, NULL },
7611 { (char *)"&Cheat", NULL, cheat_menu, 0, NULL },
7612 { (char *)"Replay", NULL, replay_menu, 0, NULL },
7613 { (char *)"&ZC", NULL, misc_menu, 0, NULL },
7614 #if DEVLEVEL > 0
7615 { (char *)"&Dev", NULL, dev_menu, 0, NULL },
7616 #endif
7617 { NULL, NULL, NULL, 0, NULL }
7618 };
7619 int32_t onPauseInBackground()
7620 {
7621 if(jwin_alert3(
7622 "Toggle Pause In Background",
7623 "This action will change whether ZC Player pauses when the window loses focus.",
7624 "",
7625 "Proceed?",
7626 "&Yes",
7627 "&No",
7628 NULL,
7629 'y',
7630 'n',
7631 0,
7632 get_zc_font(font_lfont)) == 1)
7633 {
7634 pause_in_background = pause_in_background ? 0 : 1;
7635 zc_set_config("zeldadx","pause_in_background", pause_in_background);
7636 int switch_type = pause_in_background ? SWITCH_PAUSE : SWITCH_BACKGROUND;
7637 set_display_switch_mode(fullscreen?SWITCH_BACKAMNESIA:switch_type);
7638 set_display_switch_callback(SWITCH_OUT, switch_out_callback);
7639 set_display_switch_callback(SWITCH_IN, switch_in_callback);
7640 }
7641 options_menu[4].flags =(pause_in_background)?D_SELECTED:0;
7642 return D_O_K;
7643 }
7644
7645 int32_t onKeyboardEntry()
7646 {
7647 NameEntryMode=0;
7648 zc_set_config(cfg_sect,"name_entry_mode",NameEntryMode);
7649 return D_O_K;
7650 }
7651
7652 int32_t onLetterGridEntry()
7653 {
7654 NameEntryMode=1;
7655 zc_set_config(cfg_sect,"name_entry_mode",NameEntryMode);
7656 return D_O_K;
7657 }
7658
7659 int32_t onExtLetterGridEntry()
7660 {
7661 NameEntryMode=2;
7662 zc_set_config(cfg_sect,"name_entry_mode",NameEntryMode);
7663 return D_O_K;
7664 }
7665
7666 static BITMAP* oldscreen;
7667 int32_t onFullscreenMenu()
7668 {
7669 // super hacks
7670 screen = oldscreen;
7671 if (onFullscreen() == D_REDRAW)
7672 {
7673 oldscreen = screen;
7674 }
7675 screen = menu_bmp;
7676 misc_menu[2].flags =(isFullScreen()==1)?D_SELECTED:0;
7677 return D_O_K;
7678 }
7679
7680 116 void fix_menu()
7681 {
7682
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(!debug_enabled)
7683 116 settings_menu[13].text = NULL;
7684 116 }
7685
7686 static DIALOG system_dlg[] =
7687 {
7688 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
7689 { jwin_menu_proc, 0, 0, 0, 0, 0, 0, 0, D_USER, 0, 0, (void *) the_player_menu, NULL, NULL },
7690 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F1, 0, (void *) onVsync, NULL, NULL },
7691 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F2, 0, (void *) onShowFPS, NULL, NULL },
7692 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F6, 0, (void *) onTryQuitMenu, NULL, NULL },
7693 #ifndef ALLEGRO_MACOSX
7694 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F9, 0, (void *) onReset, NULL, NULL },
7695 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F10, 0, (void *) onExit, NULL, NULL },
7696 #else
7697 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F7, 0, (void *) onReset, NULL, NULL },
7698 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F8, 0, (void *) onExit, NULL, NULL },
7699 #endif
7700 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F12, 0, (void *) onSnapshot, NULL, NULL },
7701 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_TAB, 0, (void *) onDebug, NULL, NULL },
7702 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
7703 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
7704 };
7705
7706 void reset_snapshot_format_menu()
7707 {
7708 for(int32_t i=0; i<ssfmtMAX; ++i)
7709 {
7710 snapshot_format_menu[i].flags=0;
7711 }
7712 }
7713
7714 int32_t onSetSnapshotFormat()
7715 {
7716 switch(active_menu->text[1])
7717 {
7718 case 'B': //"&BMP"
7719 SnapshotFormat=0;
7720 break;
7721
7722 case 'G': //"&GIF"
7723 SnapshotFormat=1;
7724 break;
7725
7726 case 'J': //"&JPG"
7727 SnapshotFormat=2;
7728 break;
7729
7730 case 'P': //"&PNG"
7731 SnapshotFormat=3;
7732 break;
7733
7734 case 'C': //"PC&X"
7735 SnapshotFormat=4;
7736 break;
7737
7738 case 'T': //"&TGA"
7739 SnapshotFormat=5;
7740 break;
7741
7742 case 'L': //"&LBM"
7743 SnapshotFormat=6;
7744 break;
7745 }
7746 zc_set_config("zeldadx", "snapshot_format", SnapshotFormat);
7747
7748 snapshot_format_menu[SnapshotFormat].flags=D_SELECTED;
7749 return D_O_K;
7750 }
7751
7752
7753 void color_layer(RGB *src,RGB *dest,char r,char g,char b,char pos,int32_t from,int32_t to)
7754 {
7755 PALETTE tmp;
7756
7757 for(int32_t i=0; i<256; i++)
7758 {
7759 tmp[i].r=r;
7760 tmp[i].g=g;
7761 tmp[i].b=b;
7762 }
7763
7764 fade_interpolate(src,tmp,dest,pos,from,to);
7765 }
7766
7767 14 void system_pal(bool force)
7768 {
7769
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
14 if(is_sys_pal && !force) return;
7770 14 is_sys_pal = true;
7771 14 load_colorset(gui_colorset, syspal, jwin_a5_colors);
7772 14 hw_palette = &syspal;
7773 14 update_hw_pal = true;
7774 14 }
7775
7776 static uint32_t entered_sys_pal = 0;
7777 14 void enter_sys_pal()
7778 {
7779
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(is_sys_pal)
7780 {
7781 if(entered_sys_pal)
7782 ++entered_sys_pal;
7783 return;
7784 }
7785 14 sys_mouse();
7786 14 system_pal(true);
7787 14 ++entered_sys_pal;
7788 14 }
7789 14 void exit_sys_pal()
7790 {
7791
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(entered_sys_pal)
7792 {
7793
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 if(!--entered_sys_pal)
7794 {
7795 14 game_pal();
7796 14 game_mouse();
7797 14 }
7798 14 }
7799 14 }
7800
7801 void switch_out_callback()
7802 {
7803 if (pause_in_background && !MenuOpen)
7804 {
7805 System();
7806 }
7807 }
7808
7809 void switch_in_callback()
7810 {
7811 }
7812
7813 423 void game_pal()
7814 {
7815 423 is_sys_pal = false;
7816 423 entered_sys_pal = 0;
7817 423 hw_palette = &RAMpal;
7818 423 update_hw_pal = true;
7819 423 }
7820
7821 static char bar_str[] = "";
7822
7823 14 void music_pause()
7824 {
7825 //al_pause_duh(tmplayer);
7826 14 zcmusic_pause(zcmusic, ZCM_PAUSE);
7827
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(zcmixer->oldtrack)
7828 zcmusic_pause(zcmixer->oldtrack, ZCM_PAUSE);
7829 14 zc_midi_pause();
7830 14 }
7831
7832 void music_resume()
7833 {
7834 //al_resume_duh(tmplayer);
7835 zcmusic_pause(zcmusic, ZCM_RESUME);
7836 if (zcmixer->oldtrack)
7837 zcmusic_pause(zcmixer->oldtrack, ZCM_RESUME);
7838 zc_midi_resume();
7839 }
7840
7841 3360 void music_stop()
7842 {
7843 //al_stop_duh(tmplayer);
7844 //unload_duh(tmusic);
7845 //tmusic=NULL;
7846 //tmplayer=NULL;
7847 3360 zcmusic_stop(zcmusic);
7848 3360 zcmusic_unload_file(zcmusic);
7849
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3360 times.
3360 if (zcmixer->oldtrack)
7850 {
7851 zcmusic_stop(zcmixer->oldtrack);
7852 zcmusic_unload_file(zcmixer->oldtrack);
7853 }
7854 3360 zcmixer->newtrack = NULL;
7855 3360 zc_stop_midi();
7856 3360 currmidi=-1;
7857 3360 }
7858
7859 void System()
7860 {
7861 mouse_down=gui_mouse_b();
7862 music_pause();
7863 pause_all_sfx();
7864 MenuOpen = true;
7865 enter_sys_pal();
7866 // FONT *oldfont=font;
7867 // font=tfont;
7868
7869 misc_menu[2].flags =(isFullScreen()==1)?D_SELECTED:0;
7870 misc_menu[3].flags =(isFullScreen()==1)?D_DISABLED:0;
7871
7872 game_menu[2].flags = getsaveslot() > -1 ? 0 : D_DISABLED;
7873 #if DEVLEVEL > 1
7874 dev_menu[dv_setcheat].flags = Playing ? 0 : D_DISABLED;
7875 #endif
7876 game_menu[3].flags =
7877 misc_menu[5].flags = Playing ? 0 : D_DISABLED;
7878 misc_menu[7].flags = !Playing ? 0 : D_DISABLED;
7879 clear_keybuf();
7880
7881 DIALOG_PLAYER *p;
7882
7883 clear_bitmap(menu_bmp);
7884 oldscreen = screen;
7885 screen = menu_bmp;
7886
7887 p = init_dialog(system_dlg,-1);
7888
7889 // drop the menu on startup if menu button pressed
7890 if(joybtn(Mbtn)||zc_getrawkey(KEY_ESC))
7891 simulate_keypress(KEY_G << 8);
7892
7893 do
7894 {
7895 if(handle_close_btn_quit())
7896 break;
7897
7898 rest(17);
7899
7900 if(mouse_down && !gui_mouse_b())
7901 mouse_down=0;
7902
7903 settings_menu[1].flags = replay_is_replaying() ? D_DISABLED : 0;
7904 settings_menu[5].flags = Throttlefps?D_SELECTED:0;
7905 settings_menu[6].flags = ShowFPS?D_SELECTED:0;
7906 settings_menu[7].flags = ClickToFreeze?D_SELECTED:0;
7907 settings_menu[9].flags = TransLayers?D_SELECTED:0;
7908 settings_menu[10].flags = NESquit?D_SELECTED:0;
7909 settings_menu[11].flags = volkeys?D_SELECTED:0;
7910
7911 window_menu[0].flags = DragAspect?D_SELECTED:0;
7912 window_menu[1].flags = scaleForceInteger?D_SELECTED:0;
7913 window_menu[2].flags = SaveDragResize?D_SELECTED:0;
7914 window_menu[3].flags = SaveWinPos?D_SELECTED:0;
7915 window_menu[4].flags = stretchGame?D_SELECTED:0;
7916
7917 options_menu[3].flags = (epilepsyFlashReduction) ? D_SELECTED : 0;
7918 options_menu[4].flags = (pause_in_background)?D_SELECTED:0;
7919
7920 name_entry_mode_menu[0].flags = (NameEntryMode==0)?D_SELECTED:0;
7921 name_entry_mode_menu[1].flags = (NameEntryMode==1)?D_SELECTED:0;
7922 name_entry_mode_menu[2].flags = (NameEntryMode==2)?D_SELECTED:0;
7923
7924 misc_menu[12].flags =(zasm_debugger)?D_SELECTED:0;
7925 misc_menu[13].flags =(zscript_debugger)?D_SELECTED:0;
7926 misc_menu[14].flags =(clearConsoleOnLoad)?D_SELECTED:0;
7927
7928 bool nocheat = (replay_is_replaying() || !Playing
7929 || (!zcheats.flags && !get_debug() && DEVLEVEL < 2 && !zqtesting_mode && !devpwd()));
7930 the_player_menu[2].flags = nocheat ? D_DISABLED : 0;
7931 cheat_menu[0].flags = 0;
7932 refill_menu[4].flags = get_qr(qr_TRUEARROWS) ? 0 : D_DISABLED;
7933 cheat_menu[1].text = (cheat >= 1) || get_debug() ? bar_str : NULL;
7934 cheat_menu[3].text = (cheat >= 2) || get_debug() ? bar_str : NULL;
7935 cheat_menu[8].text = (cheat >= 3) || get_debug() ? bar_str : NULL;
7936 cheat_menu[10].text = (cheat >= 4) || get_debug() ? bar_str : NULL;
7937 cheat_menu[4].flags = getClock() ? D_SELECTED : 0;
7938 cheat_menu[11].flags = toogam ? D_SELECTED : 0;
7939 cheat_menu[12].flags = ignoreSideview ? D_SELECTED : 0;
7940 cheat_menu[13].flags = gofast ? D_SELECTED : 0;
7941
7942 show_menu[0].flags = show_layer_0 ? D_SELECTED : 0;
7943 show_menu[1].flags = show_layer_1 ? D_SELECTED : 0;
7944 show_menu[2].flags = show_layer_2 ? D_SELECTED : 0;
7945 show_menu[3].flags = show_layer_3 ? D_SELECTED : 0;
7946 show_menu[4].flags = show_layer_4 ? D_SELECTED : 0;
7947 show_menu[5].flags = show_layer_5 ? D_SELECTED : 0;
7948 show_menu[6].flags = show_layer_6 ? D_SELECTED : 0;
7949 show_menu[7].flags = show_layer_over ? D_SELECTED : 0;
7950 show_menu[8].flags = show_layer_push ? D_SELECTED : 0;
7951 show_menu[9].flags = show_sprites ? D_SELECTED : 0;
7952 show_menu[10].flags = show_ffcs ? D_SELECTED : 0;
7953 show_menu[12].flags = show_walkflags ? D_SELECTED : 0;
7954 show_menu[13].flags = show_ff_scripts ? D_SELECTED : 0;
7955 show_menu[14].flags = show_hitboxes ? D_SELECTED : 0;
7956 show_menu[15].flags = show_effectflags ? D_SELECTED : 0;
7957
7958 settings_menu[8].flags = heart_beep ? D_SELECTED : 0;
7959 settings_menu[12].flags = use_save_indicator ? D_SELECTED : 0;
7960
7961 replay_menu[0].text = zc_get_config("zeldadx", "replay_new_saves", false) ?
7962 (char *)"Disable recording new saves" :
7963 (char *)"Enable recording new saves";
7964 replay_menu[1].flags = replay_is_active() ? 0 : D_DISABLED;
7965 replay_menu[1].text = replay_get_mode() == ReplayMode::Record ?
7966 (char *)"Stop recording" :
7967 (char *)"Stop replaying";
7968 replay_menu[5].flags = replay_get_mode() == ReplayMode::Record ? 0 : D_DISABLED;
7969 replay_menu[6].text = replay_is_snapshot_all_frames() ?
7970 (char *)"Disable snapshot all frames" :
7971 (char *)"Enable snapshot all frames";
7972
7973 reset_snapshot_format_menu();
7974 snapshot_format_menu[SnapshotFormat].flags = D_SELECTED;
7975
7976 if(debug_enabled)
7977 {
7978 settings_menu[14].flags = get_debug() ? D_SELECTED : 0;
7979 }
7980
7981 if(gui_mouse_b() && !mouse_down)
7982 break;
7983
7984 // press menu to drop the menu
7985 if(rMbtn())
7986 simulate_keypress(KEY_G << 8);
7987
7988 if(input_idle(true) > after_time())
7989 // run Screeen Saver
7990 {
7991 // Screen saver enabled for now.
7992 clear_keybuf();
7993 Matrix(ss_speed, ss_density, 0);
7994 system_pal(true);
7995 sys_mouse();
7996 broadcast_dialog_message(MSG_DRAW, 0);
7997 }
7998
7999 update_hw_screen();
8000 }
8001 while(update_dialog(p));
8002
8003 screen = oldscreen;
8004
8005 // font=oldfont;
8006 mouse_down=gui_mouse_b();
8007 shutdown_dialog(p);
8008 MenuOpen = false;
8009 if(Quit)
8010 {
8011 kill_sfx();
8012 music_stop();
8013 update_hw_screen();
8014 }
8015 else
8016 {
8017 music_resume();
8018 resume_all_sfx();
8019
8020 if(rc)
8021 ringcolor(false);
8022 }
8023 exit_sys_pal();
8024
8025 eat_buttons();
8026
8027 rc=false;
8028 clear_keybuf();
8029 // text_mode(0);
8030 }
8031
8032 116 void fix_dialogs()
8033 {
8034 116 jwin_center_dialog(about_dlg);
8035 116 jwin_center_dialog(gamepad_dlg);
8036 116 jwin_center_dialog(credits_dlg);
8037 116 jwin_center_dialog(gamemode_dlg);
8038 116 jwin_center_dialog(getnum_dlg);
8039 116 jwin_center_dialog(goto_dlg);
8040 116 jwin_center_dialog(keyboard_control_dlg);
8041 116 jwin_center_dialog(midi_dlg);
8042 116 jwin_center_dialog(quest_dlg);
8043 116 jwin_center_dialog(scrsaver_dlg);
8044 116 jwin_center_dialog(sound_dlg);
8045 116 jwin_center_dialog(triforce_dlg);
8046
8047 // digi_dp[1] += scrx;
8048 // digi_dp[2] += scry;
8049 // midi_dp[1] += scrx;
8050 // midi_dp[2] += scry;
8051 // pan_dp[1] += scrx;
8052 // pan_dp[2] += scry;
8053 // emus_dp[1] += scrx;
8054 // emus_dp[2] += scry;
8055 // buf_dp[1] += scrx;
8056 // buf_dp[2] += scry;
8057 // sfx_dp[1] += scrx;
8058 // sfx_dp[2] += scry;
8059 116 }
8060
8061 /*****************************/
8062 /**** Custom Sound System ****/
8063 /*****************************/
8064
8065 116 INLINE int32_t mixvol(int32_t v1,int32_t v2)
8066 {
8067
2/4
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 116 times.
✗ Branch 3 not taken.
116 return (zc_min(v1,255)*zc_min(v2,255)) >> 8;
8068 }
8069
8070 // Run an NSF, or a MIDI if the NSF is missing somehow.
8071 149 bool try_zcmusic(const char *filename, int32_t track, int32_t midi, int32_t fadeoutframes)
8072 {
8073 149 ZCMUSIC *newzcmusic = zcmusic_load_for_quest(filename, qstpath);
8074
8075 // Found it
8076
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 149 times.
149 if(newzcmusic!=NULL)
8077 {
8078 newzcmusic->fadevolume = 10000;
8079 newzcmusic->fadeoutframes = fadeoutframes;
8080
8081 zcmixer->newtrack = newzcmusic;
8082
8083 zcmusic_stop(zcmusic);
8084 zcmusic_unload_file(zcmusic);
8085 zc_stop_midi();
8086
8087 zcmusic=newzcmusic;
8088 int32_t temp_volume = emusic_volume;
8089 if (GameLoaded && !get_qr(qr_OLD_SCRIPT_VOLUME))
8090 temp_volume = (emusic_volume * FFCore.usr_music_volume) / 10000 / 100;
8091 temp_volume = (temp_volume * zcmusic->fadevolume) / 10000;
8092 zcmusic_play(zcmusic, temp_volume);
8093
8094 if(track>0)
8095 zcmusic_change_track(zcmusic,track);
8096
8097 return true;
8098 }
8099
8100 // Not found, play MIDI - unless this was called by a script (yay, magic numbers)
8101
2/2
✓ Branch 0 taken 79 times.
✓ Branch 1 taken 70 times.
149 else if(midi>-1000)
8102 70 jukebox(midi);
8103
8104 149 return false;
8105 149 }
8106
8107 bool try_zcmusic_ex(char *filename, int32_t track, int32_t midi)
8108 {
8109 ZCMUSIC *newzcmusic = zcmusic_load_for_quest(filename, qstpath);
8110 // Found it
8111 if(newzcmusic!=NULL)
8112 {
8113 zcmusic_stop(zcmusic);
8114 zcmusic_unload_file(zcmusic);
8115 zc_stop_midi();
8116
8117 zcmusic=newzcmusic;
8118 zcmusic_play(zcmusic, emusic_volume);
8119
8120 if(track>0)
8121 zcmusic_change_track(zcmusic,track);
8122
8123 return true;
8124 }
8125
8126 // Not found, play MIDI - unless this was called by a script (yay, magic numbers)
8127 else if(midi>-1000)
8128 jukebox(midi);
8129
8130 return false;
8131 }
8132
8133 int32_t get_zcmusicpos()
8134 {
8135 int32_t debugtracething = zcmusic_get_curpos(zcmusic);
8136 return debugtracething;
8137 return 0;
8138 }
8139
8140 void set_zcmusicpos(int32_t position)
8141 {
8142 zcmusic_set_curpos(zcmusic, position);
8143 }
8144
8145 void set_zcmusicspeed(int32_t speed)
8146 {
8147 zcmusic_set_speed(zcmusic, speed);
8148 }
8149
8150 int32_t get_zcmusiclen()
8151 {
8152 return zcmusic_get_length(zcmusic);
8153 }
8154
8155 void set_zcmusicloop(double start, double end)
8156 {
8157 zcmusic_set_loop(zcmusic, start, end);
8158 }
8159
8160 63941 void jukebox(int32_t index,int32_t loop)
8161 {
8162
1/2
✓ Branch 0 taken 63941 times.
✗ Branch 1 not taken.
63941 if (is_headless())
8163 63941 return;
8164
8165 music_stop();
8166
8167 if(index<0) index=MAXMIDIS-1;
8168
8169 if(index>=MAXMIDIS) index=0;
8170
8171 music_stop();
8172
8173 // Allegro's DIGMID driver (the one normally used on on Linux) gets
8174 // stuck notes when a song stops. This fixes it.
8175 if(strcmp(midi_driver->name, "DIGMID")==0)
8176 zc_set_volume(0, 0);
8177
8178 zc_set_volume(-1, mixvol(tunes[index].volume, midi_volume >>1));
8179 zc_play_midi((MIDI*)tunes[index].data,loop);
8180
8181 if(tunes[index].start>0)
8182 zc_midi_seek(tunes[index].start);
8183
8184 midi_loop_start = tunes[index].loop_start;
8185 midi_loop_end = tunes[index].loop_end;
8186
8187 currmidi=index;
8188 master_volume(digi_volume, midi_volume);
8189 //midi_paused=false;
8190 63941 }
8191
8192 63941 void jukebox(int32_t index)
8193 {
8194
1/2
✓ Branch 0 taken 63941 times.
✗ Branch 1 not taken.
63941 if(index<0) index=MAXMIDIS-1;
8195
8196
1/2
✓ Branch 0 taken 63941 times.
✗ Branch 1 not taken.
63941 if(index>=MAXMIDIS) index=0;
8197
8198 // do nothing if it's already playing
8199
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 63941 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
63941 if(index==currmidi && midi_pos>=0)
8200 {
8201 return;
8202 }
8203
8204 63941 jukebox(index,tunes[index].loop);
8205 63941 }
8206
8207 16 void play_DmapMusic()
8208 {
8209
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if (is_headless())
8210 16 return;
8211
8212 static char tfile[2048];
8213 static int32_t ttrack=0;
8214 bool domidi=false;
8215
8216 int32_t fadeoutframes = 0;
8217 if (zcmusic != NULL)
8218 fadeoutframes = zcmusic->fadeoutframes;
8219
8220 if(DMaps[currdmap].tmusic[0]!=0)
8221 {
8222 if(zcmusic==NULL ||
8223 strcmp(zcmusic->filename,DMaps[currdmap].tmusic)!=0 ||
8224 (zcmusic->type==ZCMF_GME && zcmusic->track != DMaps[currdmap].tmusictrack))
8225 {
8226 if (DMaps[currdmap].tmusic_xfade_in > 0 || fadeoutframes > 0)
8227 {
8228 if (FFCore.play_enh_music_crossfade(DMaps[currdmap].tmusic, DMaps[currdmap].tmusictrack, DMaps[currdmap].tmusic_xfade_in, fadeoutframes))
8229 {
8230 if (zcmusic != NULL)
8231 {
8232 zcmusic->fadeoutframes = DMaps[currdmap].tmusic_xfade_out;
8233 zcmusic_set_loop(zcmusic, double(DMaps[currdmap].tmusic_loop_start / 10000.0), double(DMaps[currdmap].tmusic_loop_end / 10000.0));
8234 }
8235 }
8236 }
8237 else
8238 {
8239 if (zcmusic != NULL)
8240 {
8241 zcmusic_stop(zcmusic);
8242 zcmusic_unload_file(zcmusic);
8243 zcmusic = NULL;
8244 zcmixer->newtrack = NULL;
8245 }
8246
8247 zcmusic = zcmusic_load_for_quest(DMaps[currdmap].tmusic, qstpath);
8248 zcmixer->newtrack = zcmusic;
8249
8250 if (zcmusic != NULL)
8251 {
8252 zc_stop_midi();
8253 strcpy(tfile, DMaps[currdmap].tmusic);
8254 zcmusic_play(zcmusic, emusic_volume);
8255 int32_t temptracks = 0;
8256 temptracks = zcmusic_get_tracks(zcmusic);
8257 temptracks = (temptracks < 2) ? 1 : temptracks;
8258 ttrack = vbound(DMaps[currdmap].tmusictrack, 0, temptracks - 1);
8259 zcmusic_change_track(zcmusic, ttrack);
8260 zcmusic_set_loop(zcmusic, double(DMaps[currdmap].tmusic_loop_start / 10000.0), double(DMaps[currdmap].tmusic_loop_end / 10000.0));
8261 }
8262 else
8263 {
8264 tfile[0] = 0;
8265 domidi = true;
8266 }
8267 }
8268 }
8269 }
8270 else
8271 {
8272 if (DMaps[currdmap].midi == 0 && fadeoutframes > 0 && zcmusic != NULL && strcmp(zcmusic->filename, DMaps[currdmap].tmusic) != 0)
8273 {
8274 FFCore.play_enh_music_crossfade(NULL, DMaps[currdmap].tmusictrack, DMaps[currdmap].tmusic_xfade_in, fadeoutframes);
8275 }
8276 else
8277 {
8278 domidi = true;
8279 }
8280 }
8281
8282 if(domidi)
8283 {
8284 int32_t m=DMaps[currdmap].midi;
8285
8286 switch(m)
8287 {
8288 case 1:
8289 jukebox(ZC_MIDI_OVERWORLD);
8290 break;
8291
8292 case 2:
8293 jukebox(ZC_MIDI_DUNGEON);
8294 break;
8295
8296 case 3:
8297 jukebox(ZC_MIDI_LEVEL9);
8298 break;
8299
8300 default:
8301 if(m>=4 && m<4+MAXCUSTOMMIDIS)
8302 jukebox(m+MIDIOFFSET_DMAP);
8303 else
8304 music_stop();
8305 }
8306 }
8307 16 }
8308
8309 15754 void playLevelMusic()
8310 {
8311
1/2
✓ Branch 0 taken 15754 times.
✗ Branch 1 not taken.
15754 if (is_headless())
8312 15754 return;
8313
8314 int32_t m=tmpscr->screen_midi;
8315
8316 switch(m)
8317 {
8318 case -2:
8319 music_stop();
8320 break;
8321
8322 case -1:
8323 play_DmapMusic();
8324 break;
8325
8326 case 1:
8327 jukebox(ZC_MIDI_OVERWORLD);
8328 break;
8329
8330 case 2:
8331 jukebox(ZC_MIDI_DUNGEON);
8332 break;
8333
8334 case 3:
8335 jukebox(ZC_MIDI_LEVEL9);
8336 break;
8337
8338 default:
8339 if(m>=4 && m<4+MAXCUSTOMMIDIS)
8340 jukebox(m+MIDIOFFSET_MAPSCR);
8341 else
8342 music_stop();
8343 }
8344 15754 }
8345
8346 116 void master_volume(int32_t dv,int32_t mv)
8347 {
8348
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
✓ Branch 2 taken 116 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 116 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 116 times.
✗ Branch 7 not taken.
116 if(dv>=0) digi_volume=zc_max(zc_min(dv,255),0);
8349
8350
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
✓ Branch 2 taken 116 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 116 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 116 times.
✗ Branch 7 not taken.
116 if(mv>=0) midi_volume=zc_max(zc_min(mv,255),0);
8351
8352
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
✓ Branch 2 taken 116 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 116 times.
116 int32_t i = zc_min(zc_max(currmidi,0),MAXMIDIS-1);
8353 116 int32_t temp_vol = midi_volume;
8354
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if (!get_qr(qr_OLD_SCRIPT_VOLUME))
8355 116 temp_vol = (midi_volume * FFCore.usr_music_volume) / 10000 / 100;
8356 116 zc_set_volume(digi_volume,mixvol(tunes[i].volume, temp_vol));
8357 116 }
8358
8359 /*****************/
8360 /***** SFX *****/
8361 /*****************/
8362
8363 // array of voices, one for each sfx sample in the data file
8364 // 0+ = voice #
8365 // -1 = voice not allocated
8366 116 void Z_init_sound()
8367 {
8368
2/2
✓ Branch 0 taken 29696 times.
✓ Branch 1 taken 116 times.
29812 for(int32_t i=0; i<WAV_COUNT; i++)
8369 29696 sfx_voice[i]=-1;
8370
8371 116 const char* midis[ZC_MIDI_COUNT] = {
8372 "assets/dungeon.mid",
8373 "assets/ending.mid",
8374 "assets/gameover.mid",
8375 "assets/level9.mid",
8376 "assets/overworld.mid",
8377 "assets/title.mid",
8378 "assets/triforce.mid",
8379 };
8380
2/2
✓ Branch 0 taken 812 times.
✓ Branch 1 taken 116 times.
928 for(int32_t i=0; i<ZC_MIDI_COUNT; i++)
8381 {
8382 812 tunes[i].data = load_midi(midis[i]);
8383
1/2
✓ Branch 0 taken 812 times.
✗ Branch 1 not taken.
812 if (!tunes[i].data)
8384 Z_error_fatal("Missing required file %s\n", midis[i]);
8385 812 }
8386
8387
2/2
✓ Branch 0 taken 29232 times.
✓ Branch 1 taken 116 times.
29348 for(int32_t j=0; j<MAXCUSTOMMIDIS; j++)
8388 29232 tunes[ZC_MIDI_COUNT+j].data=NULL;
8389
8390 116 master_volume(digi_volume,midi_volume);
8391 116 }
8392
8393 // returns number of voices currently allocated
8394 int32_t sfx_count()
8395 {
8396 int32_t c=0;
8397
8398 for(int32_t i=0; i<WAV_COUNT; i++)
8399 if(sfx_voice[i]!=-1)
8400 ++c;
8401
8402 return c;
8403 }
8404
8405 // clean up finished samples
8406 9217934 void sfx_cleanup()
8407 {
8408
2/2
✓ Branch 0 taken 2359791104 times.
✓ Branch 1 taken 9217934 times.
2369009038 for(int32_t i=0; i<WAV_COUNT; i++)
8409
3/4
✓ Branch 0 taken 619766 times.
✓ Branch 1 taken 2359171338 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 619766 times.
2360410870 if(sfx_voice[i]!=-1 && voice_get_position(sfx_voice[i])<0)
8410 {
8411 619766 deallocate_voice(sfx_voice[i]);
8412 619766 sfx_voice[i]=-1;
8413 619766 }
8414 9217934 }
8415
8416 // allocates a voice for the sample "wav_index" (index into zelda.dat)
8417 // if a voice is already allocated (and/or playing), then it just returns true
8418 // Returns true: voice is allocated
8419 // false: unsuccessful
8420 964184 bool sfx_init(int32_t index)
8421 {
8422 // check index
8423
3/4
✓ Branch 0 taken 721795 times.
✓ Branch 1 taken 242389 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 721795 times.
964184 if(index<=0 || index>=WAV_COUNT)
8424 242389 return false;
8425
8426
2/2
✓ Branch 0 taken 102011 times.
✓ Branch 1 taken 619784 times.
721795 if(sfx_voice[index]==-1)
8427 {
8428
2/2
✓ Branch 0 taken 209876 times.
✓ Branch 1 taken 409908 times.
619784 if(sfxdat)
8429 {
8430
1/2
✓ Branch 0 taken 209876 times.
✗ Branch 1 not taken.
209876 if(index<Z35)
8431 {
8432 209876 sfx_voice[index]=allocate_voice((SAMPLE*)sfxdata[index].dat);
8433 209876 }
8434 else
8435 {
8436 sfx_voice[index]=allocate_voice((SAMPLE*)sfxdata[Z35].dat);
8437 }
8438 209876 }
8439 else
8440 {
8441 409908 sfx_voice[index]=allocate_voice(&customsfxdata[index]);
8442 }
8443
8444 619784 int32_t temp_volume = sfx_volume;
8445
2/4
✓ Branch 0 taken 619784 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 619784 times.
✗ Branch 3 not taken.
619784 if (GameLoaded && !get_qr(qr_OLD_SCRIPT_VOLUME))
8446 temp_volume = (sfx_volume * FFCore.usr_sfx_volume) / 10000 / 100;
8447 619784 voice_set_volume(sfx_voice[index], temp_volume);
8448 619784 }
8449
8450 721795 return sfx_voice[index] != -1;
8451 964184 }
8452
8453 int32_t sfx_get_default_freq(int32_t index)
8454 {
8455 if (sfxdat)
8456 {
8457 if (index < Z35)
8458 {
8459 return ((SAMPLE*)sfxdata[index].dat)->freq;
8460 }
8461 else
8462 {
8463 return ((SAMPLE*)sfxdata[Z35].dat)->freq;
8464 }
8465 }
8466 else
8467 {
8468 return customsfxdata[index].freq;
8469 }
8470 }
8471
8472 int32_t sfx_get_length(int32_t index)
8473 {
8474 if (sfxdat)
8475 {
8476 if (index < Z35)
8477 {
8478 return int32_t(((SAMPLE*)sfxdata[index].dat)->len);
8479 }
8480 else
8481 {
8482 return int32_t(((SAMPLE*)sfxdata[Z35].dat)->len);
8483 }
8484 }
8485 else
8486 {
8487 return int32_t(customsfxdata[index].len);
8488 }
8489 }
8490
8491 // plays an sfx sample
8492 964184 void sfx(int32_t index,int32_t pan,bool loop, bool restart, int32_t vol, int32_t freq)
8493 {
8494
2/2
✓ Branch 0 taken 721795 times.
✓ Branch 1 taken 242389 times.
964184 if(!sfx_init(index))
8495 242389 return;
8496
1/2
✓ Branch 0 taken 721795 times.
✗ Branch 1 not taken.
721795 if (!is_headless())
8497 {
8498 voice_set_playmode(sfx_voice[index], loop ? PLAYMODE_LOOP : PLAYMODE_PLAY);
8499 voice_set_pan(sfx_voice[index], pan);
8500
8501 // Only used by ZScript currently
8502 if (freq <= -1)
8503 {
8504 freq = sfx_get_default_freq(index);
8505 }
8506 voice_set_frequency(sfx_voice[index], freq);
8507
8508 // Only used by ZScript currently
8509 int32_t temp_volume = (sfx_volume * vol) / 10000 / 100;
8510 if (GameLoaded && !get_qr(qr_OLD_SCRIPT_VOLUME))
8511 temp_volume = (temp_volume * FFCore.usr_sfx_volume) / 10000 / 100;
8512 voice_set_volume(sfx_voice[index], temp_volume);
8513
8514 int32_t pos = voice_get_position(sfx_voice[index]);
8515
8516 if (restart) voice_set_position(sfx_voice[index], 0);
8517
8518 if (pos <= 0)
8519 voice_start(sfx_voice[index]);
8520 }
8521
8522
3/4
✓ Branch 0 taken 398004 times.
✓ Branch 1 taken 323791 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 398004 times.
721795 if (restart && replay_is_debug())
8523
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 398004 times.
398004 replay_step_comment(fmt::format("sfx {}", sfx_string[index]));
8524 964184 }
8525
8526 // true if sfx is allocated
8527 68052 bool sfx_allocated(int32_t index)
8528 {
8529
3/4
✓ Branch 0 taken 9923 times.
✓ Branch 1 taken 58129 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 9923 times.
68052 return (index>0 && index<WAV_COUNT && sfx_voice[index]!=-1);
8530 }
8531
8532 // start it (in loop mode) if it's not already playing,
8533 // otherwise adjust it to play in loop mode -DD
8534 178223 void cont_sfx(int32_t index)
8535 {
8536
1/2
✓ Branch 0 taken 178223 times.
✗ Branch 1 not taken.
178223 if (is_headless())
8537 178223 return;
8538
8539 if(!sfx_init(index))
8540 {
8541 return;
8542 }
8543
8544 if(voice_get_position(sfx_voice[index])<=0)
8545 {
8546 voice_set_position(sfx_voice[index],0);
8547 voice_set_playmode(sfx_voice[index],PLAYMODE_LOOP);
8548 voice_start(sfx_voice[index]);
8549 }
8550 else
8551 {
8552 adjust_sfx(index, 128, true);
8553 }
8554 178223 }
8555
8556 // adjust parameters while playing
8557 4075 void adjust_sfx(int32_t index,int32_t pan,bool loop)
8558 {
8559
4/6
✓ Branch 0 taken 2315 times.
✓ Branch 1 taken 1760 times.
✓ Branch 2 taken 2315 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2315 times.
4075 if(index<=0 || index>=WAV_COUNT || sfx_voice[index]==-1)
8560 4075 return;
8561
8562 voice_set_playmode(sfx_voice[index],loop?PLAYMODE_LOOP:PLAYMODE_PLAY);
8563 voice_set_pan(sfx_voice[index],pan);
8564 4075 }
8565
8566 // pauses a voice
8567 1725 void pause_sfx(int32_t index)
8568 {
8569
3/6
✓ Branch 0 taken 1725 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1725 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1725 times.
1725 if(index>0 && index<WAV_COUNT && sfx_voice[index]!=-1)
8570 voice_stop(sfx_voice[index]);
8571 1725 }
8572
8573 // resumes a voice
8574 747 void resume_sfx(int32_t index)
8575 {
8576
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 747 times.
747 if (is_headless())
8577 747 return;
8578
8579 if(index>0 && index<WAV_COUNT && sfx_voice[index]!=-1)
8580 voice_start(sfx_voice[index]);
8581 747 }
8582
8583 // pauses all active voices
8584 452 void pause_all_sfx()
8585 {
8586
2/2
✓ Branch 0 taken 115712 times.
✓ Branch 1 taken 452 times.
116164 for(int32_t i=0; i<WAV_COUNT; i++)
8587
2/2
✓ Branch 0 taken 115711 times.
✓ Branch 1 taken 1 times.
115713 if(sfx_voice[i]!=-1)
8588 1 voice_stop(sfx_voice[i]);
8589 452 }
8590
8591 // resumes all paused voices
8592 438 void resume_all_sfx()
8593 {
8594
2/2
✓ Branch 0 taken 112128 times.
✓ Branch 1 taken 438 times.
112566 for(int32_t i=0; i<WAV_COUNT; i++)
8595
1/2
✓ Branch 0 taken 112128 times.
✗ Branch 1 not taken.
112128 if(sfx_voice[i]!=-1)
8596 voice_start(sfx_voice[i]);
8597 438 }
8598
8599 // stops an sfx and deallocates the voice
8600 7339145 void stop_sfx(int32_t index)
8601 {
8602
3/4
✓ Branch 0 taken 6190594 times.
✓ Branch 1 taken 1148551 times.
✓ Branch 2 taken 6190594 times.
✗ Branch 3 not taken.
7339145 if(index<=0 || index>=WAV_COUNT)
8603 1148551 return;
8604
8605
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 6190582 times.
6190594 if(sfx_voice[index]!=-1)
8606 {
8607 12 deallocate_voice(sfx_voice[index]);
8608 12 sfx_voice[index]=-1;
8609 12 }
8610 7339145 }
8611
8612 // Stops SFX played by Hero's item of the given family
8613 128638 void stop_item_sfx(int32_t family)
8614 {
8615 128638 int32_t id=current_item_id(family);
8616
8617
2/2
✓ Branch 0 taken 128083 times.
✓ Branch 1 taken 555 times.
128638 if(id<0)
8618 128083 return;
8619
8620 555 stop_sfx(itemsbuf[id].usesound);
8621 128638 }
8622
8623 3222 void kill_sfx()
8624 {
8625
2/2
✓ Branch 0 taken 824832 times.
✓ Branch 1 taken 3222 times.
828054 for(int32_t i=0; i<WAV_COUNT; i++)
8626
2/2
✓ Branch 0 taken 824826 times.
✓ Branch 1 taken 6 times.
824838 if(sfx_voice[i]!=-1)
8627 {
8628 6 deallocate_voice(sfx_voice[i]);
8629 6 sfx_voice[i]=-1;
8630 6 }
8631 3222 }
8632
8633 659811 int32_t pan(int32_t x)
8634 {
8635
1/4
✓ Branch 0 taken 659811 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
659811 switch(pan_style)
8636 {
8637 case 0:
8638 return 128;
8639
8640 case 1:
8641 659811 return vbound((x>>1)+68,0,255);
8642
8643 case 2:
8644 return vbound(((x*3)>>2)+36,0,255);
8645 }
8646
8647 return vbound(x,0,255);
8648 659811 }
8649
8650 /*******************************/
8651 /******* Input Handlers ********/
8652 /*******************************/
8653
8654 25092836 bool joybtn(int32_t b)
8655 {
8656
1/2
✓ Branch 0 taken 25092836 times.
✗ Branch 1 not taken.
25092836 if(b == 0)
8657 return false;
8658
1/2
✓ Branch 0 taken 25092836 times.
✗ Branch 1 not taken.
25092836 if (b-1 >= joy[joystick_index].num_buttons)
8659 25092836 return false;
8660
8661 return joy[joystick_index].button[b-1].b !=0;
8662 25092836 }
8663
8664 bool joystick(int32_t s)
8665 {
8666 if(s < 0)
8667 return false;
8668 if (s >= joy[joystick_index].num_sticks)
8669 return false;
8670
8671 for (int i = 0; i < joy[joystick_index].stick[s].num_axis; i++)
8672 {
8673 if (joy[joystick_index].stick[s].axis[i].d1 || joy[joystick_index].stick[s].axis[i].d2)
8674 return true;
8675 }
8676 return false;
8677 }
8678
8679 const char* joybtn_name(int32_t b)
8680 {
8681 if (b <= 0 || b > joy[joystick_index].num_buttons)
8682 return "";
8683
8684 return joy[joystick_index].button[b-1].name;
8685 }
8686
8687 const char* joystick_name(int32_t s)
8688 {
8689 if (s < 0 || s >= joy[joystick_index].num_sticks)
8690 return "";
8691
8692 return joy[joystick_index].stick[s].name;
8693 }
8694
8695 int32_t next_press_key();
8696
8697 int32_t next_joy_input(bool buttons)
8698 {
8699 clear_keybuf();
8700
8701 //first, we need to wait until they're pressing no buttons
8702 for(;;)
8703 {
8704 if(keypressed())
8705 {
8706 switch(readkey()>>8)
8707 {
8708 case KEY_ESC:
8709 return -1;
8710
8711 case KEY_SPACE:
8712 return 0;
8713 }
8714 }
8715
8716 poll_joystick();
8717 bool done = true;
8718
8719 if (buttons)
8720 {
8721 for(int32_t i=1; i<=joy[joystick_index].num_buttons; i++)
8722 {
8723 if(joybtn(i)) done = false;
8724 }
8725 }
8726 else
8727 {
8728 for(int32_t i=0; i<joy[joystick_index].num_sticks; i++)
8729 {
8730 if(joystick(i)) done = false;
8731 }
8732 }
8733
8734 if(done) break;
8735 rest(1);
8736 }
8737
8738 //now, we need to wait for them to press any button
8739 for(;;)
8740 {
8741 if(keypressed())
8742 {
8743 switch(readkey()>>8)
8744 {
8745 case KEY_ESC:
8746 return -1;
8747
8748 case KEY_SPACE:
8749 return 0;
8750 }
8751 }
8752
8753 poll_joystick();
8754
8755 if (buttons)
8756 {
8757 for(int32_t i=1; i<=joy[joystick_index].num_buttons; i++)
8758 {
8759 if(joybtn(i))
8760 return i;
8761 }
8762 }
8763 else
8764 {
8765 for(int32_t i=0; i<joy[joystick_index].num_sticks; i++)
8766 {
8767 if(joystick(i))
8768 return i;
8769 }
8770 }
8771 rest(1);
8772 }
8773 }
8774
8775 1205771 static bool rButton(bool &btn, bool &flag, bool rawbtn)
8776 {
8777
2/2
✓ Branch 0 taken 1201420 times.
✓ Branch 1 taken 4351 times.
1205771 bool ret = btn && !flag;
8778 1205771 flag = rawbtn;
8779
8780 1205771 return ret;
8781 }
8782 190797304 static bool rButton(bool &btn, bool &flag)
8783 {
8784
2/2
✓ Branch 0 taken 183953390 times.
✓ Branch 1 taken 6843914 times.
190797304 bool ret = btn && !flag;
8785 190797304 flag = btn;
8786
8787 190797304 return ret;
8788 }
8789 2888985 static bool rButtonPeek(bool btn, bool flag)
8790 {
8791
2/2
✓ Branch 0 taken 2685887 times.
✓ Branch 1 taken 203098 times.
2888985 if(!btn)
8792 {
8793 2685887 return false;
8794 }
8795
2/2
✓ Branch 0 taken 17939 times.
✓ Branch 1 taken 185159 times.
203098 else if(!flag)
8796 {
8797 17939 return true;
8798 }
8799
8800 185159 return false;
8801 2888985 }
8802
8803 // Updated only by keyboard/gamepad.
8804 // If in replay mode, this is set directly by the replay system.
8805 // This should never be read from directly - use control_state instead.
8806 bool raw_control_state[ZC_CONTROL_STATES];
8807
8808 // Every call to load_control_state (pretty much every frame) resets this to be equal to raw_control_state.
8809 // This state can drift from raw_control_state if button states are "eaten" or overriden by a script. But that only
8810 // lasts until the next call to load_control_state.
8811 bool control_state[ZC_CONTROL_STATES];
8812 bool disable_control[ZC_CONTROL_STATES];
8813 bool drunk_toggle_state[11];
8814 bool disabledKeys[127];
8815 bool KeyInput[127];
8816 bool KeyPress[127];
8817
8818 bool key_current_frame[127];
8819 bool key_previous_frame[127];
8820
8821 static bool key_system[127];
8822 static bool key_system_previous[127];
8823 static bool key_system_press[127];
8824
8825 bool button_press[ZC_CONTROL_STATES];
8826 bool button_hold[ZC_CONTROL_STATES];
8827
8828 #define STICK_1_X joy[joystick_index].stick[js_stick_1_x_stick].axis[js_stick_1_x_axis]
8829 #define STICK_1_Y joy[joystick_index].stick[js_stick_1_y_stick].axis[js_stick_1_y_axis]
8830 #define STICK_2_X joy[joystick_index].stick[js_stick_2_x_stick].axis[js_stick_2_x_axis]
8831 #define STICK_2_Y joy[joystick_index].stick[js_stick_2_y_stick].axis[js_stick_2_y_axis]
8832 #define STICK_PRECISION 56 //define your own sensitivity
8833
8834 7800709 void load_control_state()
8835 {
8836 7800709 load_control_called_this_frame = true;
8837
8838
2/2
✓ Branch 0 taken 4833196 times.
✓ Branch 1 taken 2967513 times.
7800709 if (replay_version_check(8, 11))
8839 {
8840
2/2
✓ Branch 0 taken 53415234 times.
✓ Branch 1 taken 2967513 times.
56382747 for (int i = 0; i < ZC_CONTROL_STATES; i++)
8841 53415234 down_control_states[i] = raw_control_state[i];
8842 2967513 }
8843
8844
1/2
✓ Branch 0 taken 7800709 times.
✗ Branch 1 not taken.
7800709 if (!replay_is_replaying())
8845 {
8846 raw_control_state[0]=zc_getrawkey(DUkey, true)||(analog_movement ? STICK_1_Y.d1 || STICK_1_Y.pos - js_stick_1_y_offset < -STICK_PRECISION : joybtn(DUbtn));
8847 raw_control_state[1]=zc_getrawkey(DDkey, true)||(analog_movement ? STICK_1_Y.d2 || STICK_1_Y.pos - js_stick_1_y_offset > STICK_PRECISION : joybtn(DDbtn));
8848 raw_control_state[2]=zc_getrawkey(DLkey, true)||(analog_movement ? STICK_1_X.d1 || STICK_1_X.pos - js_stick_1_x_offset < -STICK_PRECISION : joybtn(DLbtn));
8849 raw_control_state[3]=zc_getrawkey(DRkey, true)||(analog_movement ? STICK_1_X.d2 || STICK_1_X.pos - js_stick_1_x_offset > STICK_PRECISION : joybtn(DRbtn));
8850 raw_control_state[4]=zc_getrawkey(Akey, true)||joybtn(Abtn);
8851 raw_control_state[5]=zc_getrawkey(Bkey, true)||joybtn(Bbtn);
8852 raw_control_state[6]=zc_getrawkey(Skey, true)||joybtn(Sbtn);
8853 raw_control_state[7]=zc_getrawkey(Lkey, true)||joybtn(Lbtn);
8854 raw_control_state[8]=zc_getrawkey(Rkey, true)||joybtn(Rbtn);
8855 raw_control_state[9]=zc_getrawkey(Pkey, true)||joybtn(Pbtn);
8856 raw_control_state[10]=zc_getrawkey(Exkey1, true)||joybtn(Exbtn1);
8857 raw_control_state[11]=zc_getrawkey(Exkey2, true)||joybtn(Exbtn2);
8858 raw_control_state[12]=zc_getrawkey(Exkey3, true)||joybtn(Exbtn3);
8859 raw_control_state[13]=zc_getrawkey(Exkey4, true)||joybtn(Exbtn4);
8860
8861 if(num_joysticks != 0)
8862 {
8863 raw_control_state[14] = STICK_2_Y.pos - js_stick_2_y_offset < -STICK_PRECISION;
8864 raw_control_state[15] = STICK_2_Y.pos - js_stick_2_y_offset > STICK_PRECISION;
8865 raw_control_state[16] = STICK_2_X.pos - js_stick_2_x_offset < -STICK_PRECISION;
8866 raw_control_state[17] = STICK_2_X.pos - js_stick_2_x_offset > STICK_PRECISION;
8867 // zprint2("Detected %d joysticks... %d%d%d%d\n", num_joysticks, raw_control_state[14]?1:0, raw_control_state[15]?1:0, raw_control_state[16]?1:0, raw_control_state[17]?1:0);
8868 }
8869 else
8870 {
8871 raw_control_state[14] = false;
8872 raw_control_state[15] = false;
8873 raw_control_state[16] = false;
8874 raw_control_state[17] = false;
8875 // zprint2("Detected 0 joysticks... clearing inputaxis values.\n");
8876 }
8877 }
8878
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 7800706 times.
7800709 if (replay_is_active())
8879 {
8880
2/2
✓ Branch 0 taken 1015215 times.
✓ Branch 1 taken 6785491 times.
7800706 if (replay_get_version() < 3)
8881 1015215 replay_poll();
8882
3/4
✓ Branch 0 taken 6785491 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5024116 times.
✓ Branch 3 taken 1761375 times.
6785491 else if (replay_is_replaying() && replay_get_version() < 6)
8883 1761375 replay_peek_input();
8884
3/4
✓ Branch 0 taken 5024116 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2056603 times.
✓ Branch 3 taken 2967513 times.
5024116 else if (replay_is_replaying() && replay_version_check(8, 11))
8885 2967513 replay_peek_input();
8886
2/2
✓ Branch 0 taken 6696416 times.
✓ Branch 1 taken 1104290 times.
7800706 if (replay_get_version() == 8)
8887 1104290 update_keys();
8888 7800706 }
8889
8890 // Some test replay files were made before a serious input bug was fixed, so instead
8891 // of re-doing them or tossing them out, just check for that zplay version.
8892
3/4
✓ Branch 0 taken 7800703 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 121900 times.
✓ Branch 3 taken 7678803 times.
7800709 bool botched_input = replay_is_active() && replay_get_version() != 1 && replay_get_version() < 8;
8893
2/2
✓ Branch 0 taken 140412654 times.
✓ Branch 1 taken 7800703 times.
148213357 for (int i = 0; i < ZC_CONTROL_STATES; i++)
8894 {
8895 140412654 control_state[i] = raw_control_state[i];
8896
4/4
✓ Branch 0 taken 49487310 times.
✓ Branch 1 taken 90925344 times.
✓ Branch 2 taken 2410168 times.
✓ Branch 3 taken 47077142 times.
140412654 if (botched_input && !control_state[i])
8897 47077142 down_control_states[i] = false;
8898 140412654 }
8899 7800703 bool did_bad_cutscene_btn = false;
8900
2/2
✓ Branch 0 taken 7800703 times.
✓ Branch 1 taken 140412654 times.
148213357 for(int q = 0; q < 18; ++q)
8901
4/4
✓ Branch 0 taken 6464476 times.
✓ Branch 1 taken 133948178 times.
✓ Branch 2 taken 6463742 times.
✓ Branch 3 taken 734 times.
140413388 if(control_state[q] && !active_cutscene.can_button(q))
8902 {
8903 734 control_state[q] = false;
8904 734 did_bad_cutscene_btn = true;
8905 734 }
8906
2/2
✓ Branch 0 taken 7800188 times.
✓ Branch 1 taken 515 times.
7800703 if(did_bad_cutscene_btn)
8907 515 active_cutscene.error();
8908
8909 7800703 button_press[0]=rButton(control_state[0],button_hold[0]);
8910 7800703 button_press[1]=rButton(control_state[1],button_hold[1]);
8911 7800703 button_press[2]=rButton(control_state[2],button_hold[2]);
8912 7800703 button_press[3]=rButton(control_state[3],button_hold[3]);
8913 7800703 button_press[4]=rButton(control_state[4],button_hold[4]);
8914 7800703 button_press[5]=rButton(control_state[5],button_hold[5]);
8915 7800703 button_press[6]=rButton(control_state[6],button_hold[6]);
8916 7800703 button_press[7]=rButton(control_state[7],button_hold[7]);
8917 7800703 button_press[8]=rButton(control_state[8],button_hold[8]);
8918 7800703 button_press[9]=rButton(control_state[9],button_hold[9]);
8919 7800703 button_press[10]=rButton(control_state[10],button_hold[10]);
8920 7800703 button_press[11]=rButton(control_state[11],button_hold[11]);
8921 7800703 button_press[12]=rButton(control_state[12],button_hold[12]);
8922 7800703 button_press[13]=rButton(control_state[13],button_hold[13]);
8923 7800703 button_press[14]=rButton(control_state[14],button_hold[14]);
8924 7800703 button_press[15]=rButton(control_state[15],button_hold[15]);
8925 7800703 button_press[16]=rButton(control_state[16],button_hold[16]);
8926 7800703 button_press[17]=rButton(control_state[17],button_hold[17]);
8927 7800703 }
8928
8929 // Returns true if any game key is pressed. This is needed because keypressed()
8930 // doesn't detect modifier keys and control_state[] can be modified by scripts.
8931 40248748 bool zc_key_pressed()
8932 //may also need to use zc_getrawkey
8933 {
8934
7/10
✓ Branch 0 taken 32596311 times.
✓ Branch 1 taken 7652437 times.
✓ Branch 2 taken 7652437 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 7652437 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 6396064 times.
✓ Branch 7 taken 6396064 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 2461637 times.
42710385 if((zc_getrawkey(DUkey, true)||(analog_movement ? STICK_1_Y.d1 || STICK_1_Y.pos - js_stick_1_y_offset< -STICK_PRECISION : joybtn(DUbtn))) ||
8935
4/6
✓ Branch 0 taken 6396064 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6396064 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4843948 times.
✓ Branch 5 taken 4843948 times.
6396064 (zc_getrawkey(DDkey, true)||(analog_movement ? STICK_1_Y.d2 || STICK_1_Y.pos - js_stick_1_y_offset > STICK_PRECISION : joybtn(DDbtn))) ||
8936
4/6
✓ Branch 0 taken 4843948 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4843948 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3143103 times.
✓ Branch 5 taken 3143103 times.
4843948 (zc_getrawkey(DLkey, true)||(analog_movement ? STICK_1_X.d1 || STICK_1_X.pos - js_stick_1_x_offset < -STICK_PRECISION : joybtn(DLbtn))) ||
8937
4/6
✓ Branch 0 taken 3143103 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3143103 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2732161 times.
✓ Branch 5 taken 2732161 times.
3143103 (zc_getrawkey(DRkey, true)||(analog_movement ? STICK_1_X.d2 || STICK_1_X.pos - js_stick_1_x_offset > STICK_PRECISION : joybtn(DRbtn))) ||
8938
1/2
✓ Branch 0 taken 2732161 times.
✗ Branch 1 not taken.
2732161 (zc_getrawkey(Akey, true)||joybtn(Abtn)) ||
8939
3/4
✓ Branch 0 taken 2612754 times.
✓ Branch 1 taken 119407 times.
✓ Branch 2 taken 2612754 times.
✗ Branch 3 not taken.
2732161 (zc_getrawkey(Bkey, true)||joybtn(Bbtn)) ||
8940
3/4
✓ Branch 0 taken 2493851 times.
✓ Branch 1 taken 118903 times.
✓ Branch 2 taken 2493851 times.
✗ Branch 3 not taken.
2612754 (zc_getrawkey(Skey, true)||joybtn(Sbtn)) ||
8941
3/4
✓ Branch 0 taken 2478706 times.
✓ Branch 1 taken 15145 times.
✓ Branch 2 taken 2478706 times.
✗ Branch 3 not taken.
2493851 (zc_getrawkey(Lkey, true)||joybtn(Lbtn)) ||
8942
3/4
✓ Branch 0 taken 2465207 times.
✓ Branch 1 taken 13499 times.
✓ Branch 2 taken 2465207 times.
✗ Branch 3 not taken.
2478706 (zc_getrawkey(Rkey, true)||joybtn(Rbtn)) ||
8943
3/4
✓ Branch 0 taken 2462713 times.
✓ Branch 1 taken 2494 times.
✓ Branch 2 taken 2462713 times.
✗ Branch 3 not taken.
2465207 (zc_getrawkey(Pkey, true)||joybtn(Pbtn)) ||
8944
3/4
✓ Branch 0 taken 2462495 times.
✓ Branch 1 taken 218 times.
✓ Branch 2 taken 2462495 times.
✗ Branch 3 not taken.
2462713 (zc_getrawkey(Exkey1, true)||joybtn(Exbtn1)) ||
8945
3/4
✓ Branch 0 taken 2461656 times.
✓ Branch 1 taken 839 times.
✓ Branch 2 taken 2461656 times.
✗ Branch 3 not taken.
2462495 (zc_getrawkey(Exkey2, true)||joybtn(Exbtn2)) ||
8946
2/4
✓ Branch 0 taken 2461656 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2461656 times.
✗ Branch 3 not taken.
2461656 (zc_getrawkey(Exkey3, true)||joybtn(Exbtn3)) ||
8947
2/2
✓ Branch 0 taken 2461637 times.
✓ Branch 1 taken 19 times.
2461656 (zc_getrawkey(Exkey4, true)||joybtn(Exbtn4))) // Skipping joystick axes
8948 72017663 return true;
8949
8950 2461637 return false;
8951 9286678 }
8952
8953 150327228 bool getInput(int32_t btn, bool press, bool drunk, bool ignoreDisable, bool eatEntirely, bool peek)
8954 {
8955 150327228 bool ret = false, drunkstate = false, rawret = false;;
8956 150327228 bool* flag = &down_control_states[btn];
8957
2/7
✓ Branch 0 taken 141031213 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 9296015 times.
150327228 switch(btn)
8958 {
8959 case btnF12:
8960 ret = zc_getkey(KEY_F12, ignoreDisable);
8961 rawret = zc_getrawkey(KEY_F12, ignoreDisable);
8962 eatEntirely = false;
8963 break;
8964 case btnF11:
8965 ret = zc_getkey(KEY_F11, ignoreDisable);
8966 rawret = zc_getrawkey(KEY_F11, ignoreDisable);
8967 eatEntirely = false;
8968 break;
8969 case btnF5:
8970 ret = zc_getkey(KEY_F5, ignoreDisable);
8971 rawret = zc_getrawkey(KEY_F5, ignoreDisable);
8972 eatEntirely = false;
8973 break;
8974 case btnQ:
8975 ret = zc_getkey(KEY_Q, ignoreDisable);
8976 rawret = zc_getrawkey(KEY_Q, ignoreDisable);
8977 eatEntirely = false;
8978 break;
8979 case btnI:
8980 ret = zc_getkey(KEY_I, ignoreDisable);
8981 rawret = zc_getrawkey(KEY_I, ignoreDisable);
8982 eatEntirely = false;
8983 break;
8984 case btnM:
8985
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9296015 times.
9296015 if(FFCore.kb_typing_mode) return false;
8986 9296015 rawret = ret = zc_getrawkey(KEY_ESC, ignoreDisable);
8987 9296015 eatEntirely = false;
8988 9296015 break;
8989 default: //control_state[] index
8990
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 141031213 times.
141031213 if(FFCore.kb_typing_mode) return false;
8991
5/6
✓ Branch 0 taken 140231434 times.
✓ Branch 1 taken 799779 times.
✓ Branch 2 taken 2231197 times.
✓ Branch 3 taken 138000237 times.
✓ Branch 4 taken 2231197 times.
✗ Branch 5 not taken.
141031213 if(!ignoreDisable && get_qr(qr_FIXDRUNKINPUTS) && disable_control[btn]) drunk = false;
8992
2/2
✓ Branch 0 taken 8035911 times.
✓ Branch 1 taken 132995302 times.
141031213 else if(btn<11) drunkstate = drunk_toggle_state[btn];
8993
4/4
✓ Branch 0 taken 126864620 times.
✓ Branch 1 taken 14166593 times.
✓ Branch 2 taken 3004 times.
✓ Branch 3 taken 14163589 times.
155197806 ret = control_state[btn] && (ignoreDisable || !disable_control[btn]);
8994 141031213 rawret = raw_control_state[btn];
8995 141031213 }
8996
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 150327228 times.
150327228 assert(flag);
8997
2/2
✓ Branch 0 taken 95847822 times.
✓ Branch 1 taken 54479406 times.
150327228 if(press)
8998 {
8999
2/2
✓ Branch 0 taken 2888985 times.
✓ Branch 1 taken 51590421 times.
54479406 if(peek)
9000 2888985 ret = rButtonPeek(ret, *flag);
9001
2/2
✓ Branch 0 taken 50384650 times.
✓ Branch 1 taken 1205771 times.
51590421 else if(get_qr(qr_BROKEN_INPUT_DOWN_STATE)) ret = rButton(ret, *flag);
9002 1205771 else ret = rButton(ret, *flag, rawret);
9003 54479406 }
9004
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 150327228 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
150327228 if(eatEntirely && ret) control_state[btn] = false;
9005
3/4
✓ Branch 0 taken 112368335 times.
✓ Branch 1 taken 37958893 times.
✓ Branch 2 taken 112368335 times.
✗ Branch 3 not taken.
150327228 if(drunk && drunkstate) ret = !ret;
9006 150327228 return ret;
9007 150327228 }
9008
9009 7464828 byte getIntBtnInput(byte intbtn, bool press, bool drunk, bool ignoreDisable, bool eatEntirely, bool peek)
9010 {
9011 7464828 byte ret = 0;
9012
2/2
✓ Branch 0 taken 5485508 times.
✓ Branch 1 taken 1979320 times.
7464828 if(intbtn & INT_BTN_A) ret |= getInput(btnA, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_A : 0;
9013
2/2
✓ Branch 0 taken 7334014 times.
✓ Branch 1 taken 130814 times.
7464828 if(intbtn & INT_BTN_B) ret |= getInput(btnB, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_B : 0;
9014
2/2
✓ Branch 0 taken 7334139 times.
✓ Branch 1 taken 130689 times.
7464828 if(intbtn & INT_BTN_L) ret |= getInput(btnL, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_L : 0;
9015
2/2
✓ Branch 0 taken 7334139 times.
✓ Branch 1 taken 130689 times.
7464828 if(intbtn & INT_BTN_R) ret |= getInput(btnR, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_R : 0;
9016
2/2
✓ Branch 0 taken 7334139 times.
✓ Branch 1 taken 130689 times.
7464828 if(intbtn & INT_BTN_EX1) ret |= getInput(btnEx1, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX1 : 0;
9017
2/2
✓ Branch 0 taken 7334139 times.
✓ Branch 1 taken 130689 times.
7464828 if(intbtn & INT_BTN_EX2) ret |= getInput(btnEx2, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX2 : 0;
9018
2/2
✓ Branch 0 taken 7334139 times.
✓ Branch 1 taken 130689 times.
7464828 if(intbtn & INT_BTN_EX3) ret |= getInput(btnEx3, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX3 : 0;
9019
2/2
✓ Branch 0 taken 7334139 times.
✓ Branch 1 taken 130689 times.
7464828 if(intbtn & INT_BTN_EX4) ret |= getInput(btnEx4, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX4 : 0;
9020 7464828 return ret; //No early return, to make sure all button presses are eaten that should be! -Em
9021 }
9022
9023 1114 byte checkIntBtnVal(byte intbtn, byte vals)
9024 {
9025 1114 return intbtn&vals;
9026 }
9027
9028 1767383 bool Up()
9029 {
9030 1767383 return getInput(btnUp);
9031 }
9032 147167 bool Down()
9033 {
9034 147167 return getInput(btnDown);
9035 }
9036 257581 bool Left()
9037 {
9038 257581 return getInput(btnLeft);
9039 }
9040 286774 bool Right()
9041 {
9042 286774 return getInput(btnRight);
9043 }
9044 164908 bool cAbtn()
9045 {
9046 164908 return getInput(btnA);
9047 }
9048 1411891 bool cBbtn()
9049 {
9050 1411891 return getInput(btnB);
9051 }
9052 bool cSbtn()
9053 {
9054 return getInput(btnS);
9055 }
9056 68744 bool cLbtn()
9057 {
9058 68744 return getInput(btnL);
9059 }
9060 68744 bool cRbtn()
9061 {
9062 68744 return getInput(btnR);
9063 }
9064 bool cPbtn()
9065 {
9066 return getInput(btnP);
9067 }
9068 bool cEx1btn()
9069 {
9070 return getInput(btnEx1);
9071 }
9072 bool cEx2btn()
9073 {
9074 return getInput(btnEx2);
9075 }
9076 bool cEx3btn()
9077 {
9078 return getInput(btnEx3);
9079 }
9080 bool cEx4btn()
9081 {
9082 return getInput(btnEx4);
9083 }
9084 bool AxisUp()
9085 {
9086 return getInput(btnAxisUp);
9087 }
9088 bool AxisDown()
9089 {
9090 return getInput(btnAxisDown);
9091 }
9092 bool AxisLeft()
9093 {
9094 return getInput(btnAxisLeft);
9095 }
9096 bool AxisRight()
9097 {
9098 return getInput(btnAxisRight);
9099 }
9100
9101 bool cMbtn()
9102 {
9103 return getInput(btnM);
9104 }
9105 bool cF12()
9106 {
9107 return getInput(btnF12);
9108 }
9109 bool cF11()
9110 {
9111 return getInput(btnF11);
9112 }
9113 bool cF5()
9114 {
9115 return getInput(btnF5);
9116 }
9117 bool cQ()
9118 {
9119 return getInput(btnQ);
9120 }
9121 bool cI()
9122 {
9123 return getInput(btnI);
9124 }
9125
9126 130270 bool rUp()
9127 {
9128 130270 return getInput(btnUp, true);
9129 }
9130 130174 bool rDown()
9131 {
9132 130174 return getInput(btnDown, true);
9133 }
9134 130122 bool rLeft()
9135 {
9136 130122 return getInput(btnLeft, true);
9137 }
9138 129657 bool rRight()
9139 {
9140 129657 return getInput(btnRight, true);
9141 }
9142 1296 bool rAbtn()
9143 {
9144 1296 return getInput(btnA, true);
9145 }
9146 1296 bool rBbtn()
9147 {
9148 1296 return getInput(btnB, true);
9149 }
9150 7396643 bool rSbtn()
9151 {
9152 7396643 return getInput(btnS, true);
9153 }
9154 9286678 bool rMbtn()
9155 {
9156 9286678 return getInput(btnM, true);
9157 }
9158 129441 bool rLbtn()
9159 {
9160 129441 return getInput(btnL, true);
9161 }
9162 129436 bool rRbtn()
9163 {
9164 129436 return getInput(btnR, true);
9165 }
9166 7333107 bool rPbtn()
9167 {
9168 7333107 return getInput(btnP, true);
9169 }
9170 bool rEx1btn()
9171 {
9172 return getInput(btnEx1, true);
9173 }
9174 bool rEx2btn()
9175 {
9176 return getInput(btnEx2, true);
9177 }
9178 140087 bool rEx3btn()
9179 {
9180 140087 return getInput(btnEx3, true);
9181 }
9182 140087 bool rEx4btn()
9183 {
9184 140087 return getInput(btnEx4, true);
9185 }
9186 bool rAxisUp()
9187 {
9188 return getInput(btnAxisUp, true);
9189 }
9190 bool rAxisDown()
9191 {
9192 return getInput(btnAxisDown, true);
9193 }
9194 bool rAxisLeft()
9195 {
9196 return getInput(btnAxisLeft, true);
9197 }
9198 bool rAxisRight()
9199 {
9200 return getInput(btnAxisRight, true);
9201 }
9202
9203 bool rF11()
9204 {
9205 return getInput(btnF11, true);
9206 }
9207 bool rQ()
9208 {
9209 return getInput(btnQ, true);
9210 }
9211 bool rI()
9212 {
9213 return getInput(btnI, true);
9214 }
9215
9216 18226189 bool DrunkUp()
9217 {
9218 18226189 return getInput(btnUp, false, true);
9219 }
9220 16889179 bool DrunkDown()
9221 {
9222 16889179 return getInput(btnDown, false, true);
9223 }
9224 10288364 bool DrunkLeft()
9225 {
9226 10288364 return getInput(btnLeft, false, true);
9227 }
9228 8834095 bool DrunkRight()
9229 {
9230 8834095 return getInput(btnRight, false, true);
9231 }
9232 8035553 bool DrunkcAbtn()
9233 {
9234 8035553 return getInput(btnA, false, true);
9235 }
9236 8017001 bool DrunkcBbtn()
9237 {
9238 8017001 return getInput(btnB, false, true);
9239 }
9240 7263977 bool DrunkcEx1btn()
9241 {
9242 7263977 return getInput(btnEx1, false, true);
9243 }
9244 7263997 bool DrunkcEx2btn()
9245 {
9246 7263997 return getInput(btnEx2, false, true);
9247 }
9248 bool DrunkcSbtn()
9249 {
9250 return getInput(btnS, false, true);
9251 }
9252 bool DrunkcMbtn()
9253 {
9254 return getInput(btnM, false, true);
9255 }
9256 bool DrunkcLbtn()
9257 {
9258 return getInput(btnL, false, true);
9259 }
9260 bool DrunkcRbtn()
9261 {
9262 return getInput(btnR, false, true);
9263 }
9264 bool DrunkcPbtn()
9265 {
9266 return getInput(btnP, false, true);
9267 }
9268
9269 bool DrunkrUp()
9270 {
9271 return getInput(btnUp, true, true);
9272 }
9273 bool DrunkrDown()
9274 {
9275 return getInput(btnDown, true, true);
9276 }
9277 bool DrunkrLeft()
9278 {
9279 return getInput(btnLeft, true, true);
9280 }
9281 bool DrunkrRight()
9282 {
9283 return getInput(btnRight, true, true);
9284 }
9285 6081761 bool DrunkrAbtn()
9286 {
9287 6081761 return getInput(btnA, true, true);
9288 }
9289 6098593 bool DrunkrBbtn()
9290 {
9291 6098593 return getInput(btnB, true, true);
9292 }
9293 71669 bool DrunkrEx1btn()
9294 {
9295 71669 return getInput(btnEx1, true, true);
9296 }
9297 71662 bool DrunkrEx2btn()
9298 {
9299 71662 return getInput(btnEx2, true, true);
9300 }
9301 bool DrunkrEx3btn()
9302 {
9303 return getInput(btnEx3, true, true);
9304 }
9305 bool DrunkrEx4btn()
9306 {
9307 return getInput(btnEx4, true, true);
9308 }
9309 bool DrunkrSbtn()
9310 {
9311 return getInput(btnS, true, true);
9312 }
9313 bool DrunkrMbtn()
9314 {
9315 return getInput(btnM, true, true);
9316 }
9317 6688759 bool DrunkrLbtn()
9318 {
9319 6688759 return getInput(btnL, true, true);
9320 }
9321 6685284 bool DrunkrRbtn()
9322 {
9323 6685284 return getInput(btnR, true, true);
9324 }
9325 bool DrunkrPbtn()
9326 {
9327 return getInput(btnP, true, true);
9328 }
9329
9330 9337 void eat_buttons()
9331 {
9332 9337 getInput(btnA, true, false, true);
9333 9337 getInput(btnB, true, false, true);
9334 9337 getInput(btnS, true, false, true);
9335 9337 getInput(btnM, true, false, true);
9336 9337 getInput(btnL, true, false, true);
9337 9337 getInput(btnR, true, false, true);
9338 9337 getInput(btnP, true, false, true);
9339 9337 getInput(btnEx1, true, false, true);
9340 9337 getInput(btnEx2, true, false, true);
9341 9337 getInput(btnEx3, true, false, true);
9342 9337 getInput(btnEx4, true, false, true);
9343 9337 }
9344
9345 // Is true for the _first frame_ of a key press.
9346 // But! it is possible that a script manually sets the value of KeyPress,
9347 // in which case it will be restored to the "true" value based on `key_current_frame`
9348 // and `key_previous_frame` on the next frame.
9349 14 bool zc_readkey(int32_t k, bool ignoreDisable)
9350 {
9351
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(ignoreDisable) return KeyPress[k];
9352
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 switch(k)
9353 {
9354 case KEY_F7:
9355 case KEY_F8:
9356 case KEY_F9:
9357 return KeyPress[k];
9358
9359 default:
9360
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 return KeyPress[k] && !disabledKeys[k];
9361 }
9362 14 }
9363
9364 // Is true for _every frame_ a key is held down.
9365 // But! it is possible that a script manually sets the value of KeyInput,
9366 // in which case it will be restored to the "true" value based on `key_current_frame`
9367 // on the next frame.
9368 bool zc_getkey(int32_t k, bool ignoreDisable)
9369 {
9370 if(ignoreDisable) return KeyInput[k];
9371 switch(k)
9372 {
9373 case KEY_F7:
9374 case KEY_F8:
9375 case KEY_F9:
9376 return KeyInput[k];
9377
9378 default:
9379 return KeyInput[k] && !disabledKeys[k];
9380 }
9381 }
9382
9383 // Reads (and then clears) the current frame key state directly.
9384 // Scripts can also modify `key_current_frame`.
9385 303 bool zc_readrawkey(int32_t k, bool ignoreDisable)
9386 {
9387
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 301 times.
303 if(zc_getrawkey(k, ignoreDisable))
9388 {
9389 2 _key[k]=key[k]=key_current_frame[k]=0;
9390 2 return true;
9391 }
9392 301 _key[k]=key[k]=key_current_frame[k]=0;
9393 301 return false;
9394 303 }
9395
9396 // Reads the current frame key state directly.
9397 // Scripts can also modify `key_current_frame`.
9398 63249747 bool zc_getrawkey(int32_t k, bool ignoreDisable)
9399 {
9400
2/2
✓ Branch 0 taken 53963041 times.
✓ Branch 1 taken 9286706 times.
63249747 if(ignoreDisable) return key_current_frame[k];
9401
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9286706 times.
9286706 switch(k)
9402 {
9403 case KEY_F7:
9404 case KEY_F8:
9405 case KEY_F9:
9406 return key_current_frame[k];
9407
9408 default:
9409
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9286706 times.
9286706 return key_current_frame[k] && !disabledKeys[k];
9410 }
9411 63249747 }
9412
9413 // Only used for a handful of keys, like tilde and Function keys.
9414 // This state is never read within the game.
9415 // It exists so that all keyboard input still functions during replay,
9416 // without inadvertently doing things like toggling throttling if the player
9417 // presses ~
9418 9286678 bool zc_get_system_key(int32_t k)
9419 {
9420 9286678 return key_system[k];
9421 }
9422
9423 // True for the _first_ frame of a key press.
9424 83580102 bool zc_read_system_key(int32_t k)
9425 {
9426 83580102 return key_system_press[k];
9427 }
9428
9429 1179408106 bool is_system_key(int32_t k)
9430 {
9431
2/2
✓ Branch 0 taken 1095828004 times.
✓ Branch 1 taken 83580102 times.
1179408106 switch (k)
9432 {
9433 case KEY_BACKQUOTE:
9434 case KEY_CLOSEBRACE:
9435 case KEY_END:
9436 case KEY_HOME:
9437 case KEY_OPENBRACE:
9438 case KEY_PGDN:
9439 case KEY_PGUP:
9440 case KEY_TAB:
9441 case KEY_TILDE:
9442 83580102 return true;
9443 }
9444 1095828004 return is_Fkey(k);
9445 1179408106 }
9446
9447 9286678 void update_system_keys()
9448 {
9449
2/2
✓ Branch 0 taken 1179408106 times.
✓ Branch 1 taken 9286678 times.
1188694784 for (int32_t q = 0; q < 127; ++q)
9450 {
9451
2/2
✓ Branch 0 taken 195020238 times.
✓ Branch 1 taken 984387868 times.
1179408106 if (!is_system_key(q))
9452 984387868 continue;
9453
9454 195020238 key_system[q] = key[q];
9455
1/2
✓ Branch 0 taken 195020238 times.
✗ Branch 1 not taken.
195020238 key_system_press[q] = key_system[q] && !key_system_previous[q];
9456 195020238 key_system_previous[q] = key_system[q];
9457 195020238 }
9458 9286678 }
9459
9460 10390968 void update_keys()
9461 {
9462
2/2
✓ Branch 0 taken 1319652936 times.
✓ Branch 1 taken 10390968 times.
1330043904 for (int32_t q = 0; q < 127; ++q)
9463 {
9464 // When replaying, replay.cpp takes care of updating `key_current_frame`.
9465
1/2
✓ Branch 0 taken 1319652936 times.
✗ Branch 1 not taken.
1319652936 if (!replay_is_replaying())
9466 key_current_frame[q] = key[q];
9467
9468
2/2
✓ Branch 0 taken 1309864938 times.
✓ Branch 1 taken 9787998 times.
1319652936 KeyPress[q] = key_current_frame[q] && !key_previous_frame[q];
9469 1319652936 KeyInput[q] = key_current_frame[q];
9470 1319652936 key_previous_frame[q] = key_current_frame[q];
9471 1319652936 }
9472 10390968 }
9473
9474 bool zc_disablekey(int32_t k, bool val)
9475 {
9476 switch(k)
9477 {
9478 case KEY_F7:
9479 case KEY_F8:
9480 case KEY_F9:
9481 return false;
9482
9483 default:
9484 disabledKeys[k] = val;
9485 return true;
9486 }
9487 }
9488
9489 void zc_putpixel(int32_t layer, int32_t x, int32_t y, int32_t cset, int32_t color, int32_t timer)
9490 {
9491 timer=timer;
9492 particles.add(new particle(zfix(x), zfix(y), layer, cset, color));
9493 }
9494